Skip to content

Commit

Permalink
fix(TDOPS-5665): Add changes for tools folder + remove scripts folder…
Browse files Browse the repository at this point in the history
… and update root package.json (#4984)
  • Loading branch information
smouillour authored Nov 14, 2023
1 parent ce14407 commit 6739849
Show file tree
Hide file tree
Showing 92 changed files with 1,265 additions and 389 deletions.
5 changes: 5 additions & 0 deletions .changeset/chatty-timers-exercise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@talend/scripts-publish-local': minor
---

Add missing deps
5 changes: 5 additions & 0 deletions .changeset/chilly-lies-pump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@talend/babel-plugin-import-d3': minor
---

Add missing deps and fix lint issues
5 changes: 5 additions & 0 deletions .changeset/fair-candles-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@talend/eslint-plugin': minor
---

remove dep with scripts-core and fix eslint config (circular dependency)
5 changes: 5 additions & 0 deletions .changeset/fair-fans-exercise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@talend/scripts-build-cdn': minor
---

Add missing deps, remove dependency with scripts-core (circular dependency) and adapt code for PNPM
5 changes: 5 additions & 0 deletions .changeset/famous-ghosts-guess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@talend/scripts-cmf': minor
---

add missing deps, remove link with scripts-core (circular dependency)
5 changes: 5 additions & 0 deletions .changeset/giant-bobcats-drum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@talend/scripts-core': minor
---

Improve peerDependencies and add missing deps to not have circular dependency, adapt code to be compatible with PNPM and fix tests
5 changes: 5 additions & 0 deletions .changeset/gorgeous-singers-whisper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@talend/scripts-config-storybook-lib': minor
---

Add missing deps, upgrade msw to v1.3.2
5 changes: 5 additions & 0 deletions .changeset/green-shoes-lay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@talend/babel-plugin-import-from-index': minor
---

add missing deps, fix eslint config (circular dependency) and fix lint issues
5 changes: 5 additions & 0 deletions .changeset/nine-bikes-bathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@talend/scripts-config-react-webpack': minor
---

Add missing deps, make talend/icons as peerDependency to remove circular dependency and adapt webpack config files for pnpm
5 changes: 5 additions & 0 deletions .changeset/pink-penguins-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@talend/scripts-yarn-workspace': minor
---

Add missing deps
5 changes: 5 additions & 0 deletions .changeset/proud-spiders-provide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@talend/scripts-config-typescript': minor
---

Add missing deps, Remove link with scripts-core (circular dependency) and fix tsconfig file
5 changes: 5 additions & 0 deletions .changeset/quiet-worms-reflect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@talend/upgrade-deps': minor
---

Add missing deps
5 changes: 5 additions & 0 deletions .changeset/rich-ladybugs-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@talend/scripts-config-stylelint': minor
---

Add missing deps
5 changes: 5 additions & 0 deletions .changeset/short-crabs-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@talend/scripts-config-jest': minor
---

Fix peer dependencies, Add lint
5 changes: 5 additions & 0 deletions .changeset/silent-wasps-camp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@talend/cypress-api-mock-plugin': minor
---

Add missing deps and fix lint issues
5 changes: 5 additions & 0 deletions .changeset/silver-flowers-smell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@talend/scripts-utils': minor
---

Add missing deps and revert change about eslint config to use the talend one
5 changes: 5 additions & 0 deletions .changeset/slimy-boats-whisper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@talend/scripts-config-cdn': minor
---

Add missing deps, adapt cdn code for pnpm and fix eslint config (circular dependency)
5 changes: 5 additions & 0 deletions .changeset/slimy-islands-yell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@talend/scripts-teorem': minor
---

Add missing deps
5 changes: 5 additions & 0 deletions .changeset/soft-years-poke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@talend/babel-plugin-import-from-lib': minor
---

Add missing deps and fix lint issues
5 changes: 5 additions & 0 deletions .changeset/strong-balloons-tell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@talend/scripts-locales': minor
---

Add missing deps and fix lint
5 changes: 5 additions & 0 deletions .changeset/tender-cooks-hope.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@talend/babel-plugin-assets-api': minor
---

Add missing deps, fix eslint config (circular dependency) and fix lint issues
5 changes: 5 additions & 0 deletions .changeset/thin-pillows-smell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@talend/scripts-config-prettier': minor
---

Add missing deps, remove link with scripts-core (circular dependency) and fix prettier config to be compatible with prettier 3
5 changes: 5 additions & 0 deletions .changeset/thirty-scissors-dress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@talend/scripts-config-babel': minor
---

fix plugin order for eslint and fix eslint config (circular dep)
2 changes: 1 addition & 1 deletion .github/actions/setup-node/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ runs:
- name: Set up Node.js
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d #v3.8.1
with:
node-version: '20'
node-version-file: '.tool-versions'
registry-url: 'https://registry.npmjs.org/'
scope: '@talend'

Expand Down
25 changes: 14 additions & 11 deletions .github/workflows/pr-demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,32 @@ jobs:
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac #v4.0.0

- name: Use Node.js
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
with:
node-version: 18
registry-url: "https://registry.npmjs.org/"
scope: "@talend"
cache: "yarn"
uses: ./.github/actions/setup-node

- name: cache for storybook
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 #v3.3.2
with:
path: packages/*/node_modules
key: ${{ runner.os }}-${{ hashFiles('yarn.lock') }}
key: ${{ runner.os }}-storybook-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-storybook-
- name: Install
run: |
node --version
yarn install --frozen-lockfile
yarn global add surge
echo "$(yarn global bin)" >> $GITHUB_PATH
- name: Build
- name: Run test:demo
run: |
node --version
yarn test:demo
- name: Before surge
run: |
node --version
yarn global add surge
echo "$(yarn global bin)" >> $GITHUB_PATH
node --version
./.github/workflows/before-surge.sh
env:
STORYBOOK_FIGMA_ACCESS_TOKEN: ${{ secrets.STORYBOOK_FIGMA_ACCESS_TOKEN }}
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/pr-playground.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ jobs:
- name: Checkout sources
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac #v4.0.0

- name: Use Node.js
uses: ./.github/actions/setup-node

- name: Check node version
run: |
node --version
- name: Check UMD files size diff
uses: preactjs/compressed-size-action@8119d3d31b6e57b167e09c81dfa877eada3bcb35 #v2.5.0
if: github.ref != 'refs/heads/master'
Expand Down
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 20.9.0
14 changes: 6 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
{
"devDependencies": {
"@changesets/cli": "^2.26.2",
"@talend/scripts-config-prettier": "^12.0.0",
"@talend/scripts-config-babel": "^13.1.0",
"@talend/scripts-yarn-workspace": "^1.2.0",
"cross-env": "^7.0.3",
"cross-spawn": "^7.0.3",
"eslint": "^8.53.0",
"husky": "^8.0.3",
"i18next-scanner": "^4.4.0",
"lint-staged": "^13.3.0",
"prettier": "^3.0.3"
"prettier": "^3.0.3",
"rimraf": "^3.0.2",
"typescript": "^5.0.4"
},
"scripts": {
"postinstall": "talend-yarn-workspace run build:lib",
Expand Down Expand Up @@ -58,12 +63,5 @@
"*.{json,md,mdx,html,js,jsx,ts,tsx}": [
"prettier --write"
]
},
"dependencies": {
"@types/react": "^18.2.7",
"@types/react-dom": "^18.2.15",
"terser-webpack-plugin": "^5.3.9",
"typescript": "^5.2.2",
"webpack": "^5.89.0"
}
}
7 changes: 0 additions & 7 deletions scripts/get-locations.js

This file was deleted.

14 changes: 13 additions & 1 deletion tools/babel-plugin-assets-api/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
{
"root": true,
"extends": "@talend"
"extends": ["eslint:recommended", "plugin:prettier/recommended", "plugin:import/recommended"],
"env": {
"es6": true,
"node": true,
"jasmine": true,
"jest": true
},
"parser": "@babel/eslint-parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"requireConfigFile": false
}
}
4 changes: 3 additions & 1 deletion tools/babel-plugin-assets-api/__fixtures__/first/output.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/* eslint-disable @typescript-eslint/no-unused-vars */

/* eslint-disable import/no-extraneous-dependencies */
import assetsAPI from '@talend/assets-api';
import React from 'react';

import assetsAPI from '@talend/assets-api';

assetsAPI.getURL('/', 'react', '18.2.0');
assetsAPI.getURL('/', 'react', '16.13.0');
assetsAPI.getJSON('/foo.json', 'react', '18.2.0');
Expand Down
7 changes: 5 additions & 2 deletions tools/babel-plugin-assets-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "",
"main": "src/index.js",
"scripts": {
"lint": "talend-scripts lint",
"lint": "eslint ./src",
"test": "jest"
},
"dependencies": {
Expand All @@ -13,10 +13,13 @@
},
"devDependencies": {
"@babel/core": "^7.23.3",
"@babel/eslint-parser": "^7.23.3",
"@babel/preset-env": "^7.23.3",
"babel-jest": "^29.7.0",
"babel-plugin-tester": "^10.1.0",
"jest": "^29.7.0"
"eslint": "^8.53.0",
"jest": "^29.7.0",
"react": "^18.2.0"
},
"jest": {
"verbose": true,
Expand Down
1 change: 1 addition & 0 deletions tools/babel-plugin-assets-api/src/index.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pluginTester, { prettierFormatter } from 'babel-plugin-tester';
import path from 'path';

import babelPlugin from '.';

pluginTester({
Expand Down
3 changes: 3 additions & 0 deletions tools/babel-plugin-import-d3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"test": "jest"
},
"devDependencies": {
"@talend/eslint-config": "^12.2.0",
"@talend/eslint-plugin": "^1.0.1",
"@talend/scripts-core": "^16.1.0",
"@babel/core": "^7.23.3",
"@babel/preset-env": "^7.23.3",
"babel-jest": "^29.7.0",
Expand Down
26 changes: 5 additions & 21 deletions tools/babel-plugin-import-d3/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,6 @@ function findD3RelatedPackageName(importDeclarationPath) {
return found;
}

function getLastNameInPath(path) {
const splited = path.split('/');
if (splited.length === 1) {
return false;
}
return splited.pop();
}

function sortImports(a, b) {
if (a.type === 'ImportDefaultSpecifier') {
return -1;
Expand All @@ -62,35 +54,31 @@ module.exports = function transform({ types }) {
const d3Packages = [];
const requireCalls = [];
let lastImport;
let realLastImport;

path.traverse({
CallExpression: {
exit(callExpression) {
if (callExpression.node.callee.name === 'require') {
if (PACKAGES.indexOf(callExpression.node.arguments[0].value) !== -1) {
const mod = callExpression.node.arguments[0].value.replace('d3-', '');
// eslint-disable-next-line no-param-reassign
callExpression.node.arguments[0] = types.stringLiteral('d3');
// we must wrap callexpression into memberexpression
requireCalls.push({
callExpression,
replace: types.memberExpression(
callExpression.node,
types.identifier(mod),
)
replace: types.memberExpression(callExpression.node, types.identifier(mod)),
});
callExpression.remove();
}
}
}
},
},
ImportDeclaration: {
exit(importDeclarationPath) {
realLastImport = importDeclarationPath;
const packageName = findD3RelatedPackageName(importDeclarationPath);
if (packageName) {
d3Packages.push(
...importDeclarationPath.node.specifiers.map(({ local, imported, type }) => {
...importDeclarationPath.node.specifiers.map(({ local, imported }) => {
const localName = local.name;
let importedName = localName;
if (imported) {
Expand All @@ -112,13 +100,9 @@ module.exports = function transform({ types }) {
requireCalls.forEach(info => {
info.callExpression.insertAfter(info.replace);
});
const packageName = 'd3';
if (d3Packages.length > 0) {
const source = types.stringLiteral('d3');
const imp = types.importDeclaration(
d3Packages.filter(Boolean).sort(sortImports),
source,
);
const imp = types.importDeclaration(d3Packages.filter(Boolean).sort(sortImports), source);
if (lastImport) {
lastImport.insertAfter(imp);
}
Expand Down
Loading

0 comments on commit 6739849

Please sign in to comment.