From 101e6c41b49aaa338b252e9f6c2eccfdaff438fa Mon Sep 17 00:00:00 2001 From: Jean-Michel FRANCOIS Date: Mon, 8 Jul 2024 10:55:49 +0200 Subject: [PATCH] chore: remove scripts-build-cdn from this repository (#5306) --- .prettierignore | 1 + tools/scripts-build-cdn/.eslintrc.json | 4 - tools/scripts-build-cdn/.gitignore | 3 - tools/scripts-build-cdn/CHANGELOG.md | 180 --------------- tools/scripts-build-cdn/README.md | 38 --- tools/scripts-build-cdn/build.js | 216 ------------------ tools/scripts-build-cdn/clean.js | 40 ---- tools/scripts-build-cdn/download.js | 151 ------------ tools/scripts-build-cdn/getInfo.js | 145 ------------ tools/scripts-build-cdn/index.js | 42 ---- tools/scripts-build-cdn/package.json | 46 ---- .../patch/@popperjs/core/2.5.0/package.json | 9 - 12 files changed, 1 insertion(+), 874 deletions(-) delete mode 100644 tools/scripts-build-cdn/.eslintrc.json delete mode 100644 tools/scripts-build-cdn/.gitignore delete mode 100644 tools/scripts-build-cdn/CHANGELOG.md delete mode 100644 tools/scripts-build-cdn/README.md delete mode 100755 tools/scripts-build-cdn/build.js delete mode 100644 tools/scripts-build-cdn/clean.js delete mode 100644 tools/scripts-build-cdn/download.js delete mode 100644 tools/scripts-build-cdn/getInfo.js delete mode 100755 tools/scripts-build-cdn/index.js delete mode 100644 tools/scripts-build-cdn/package.json delete mode 100644 tools/scripts-build-cdn/patch/@popperjs/core/2.5.0/package.json diff --git a/.prettierignore b/.prettierignore index da1cc32ff32..34f6040084a 100644 --- a/.prettierignore +++ b/.prettierignore @@ -7,3 +7,4 @@ build dist node_modules __fixtures__ +tools/scripts-config-storybook-lib/.storybook-templates/main.js diff --git a/tools/scripts-build-cdn/.eslintrc.json b/tools/scripts-build-cdn/.eslintrc.json deleted file mode 100644 index 8464e11418a..00000000000 --- a/tools/scripts-build-cdn/.eslintrc.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "root": true, - "extends": "@talend" -} diff --git a/tools/scripts-build-cdn/.gitignore b/tools/scripts-build-cdn/.gitignore deleted file mode 100644 index 493fada619d..00000000000 --- a/tools/scripts-build-cdn/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/dist -/.test-cache -talend-umds \ No newline at end of file diff --git a/tools/scripts-build-cdn/CHANGELOG.md b/tools/scripts-build-cdn/CHANGELOG.md deleted file mode 100644 index 7cdd39ecf8c..00000000000 --- a/tools/scripts-build-cdn/CHANGELOG.md +++ /dev/null @@ -1,180 +0,0 @@ -# @talend/scripts-build-cdn - -## 11.2.0 - -### Minor Changes - -- c3750a1: chore: upgrade dependencies - - Major upgrade for all packages that have a peerDependency on react or react-dom. Those packages now ask for react@18 and react-dom@18. - -### Patch Changes - -- Updated dependencies [c3750a1] - - @talend/babel-plugin-import-d3@0.5.0 - - @talend/scripts-config-cdn@10.12.0 - - @talend/module-to-cdn@9.11.0 - -## 11.1.3 - -### Patch Changes - -- af0ac2d: Upgrade rimraf to version 5.0.5 - -## 11.1.2 - -### Patch Changes - -- 1abc22f: chore: upgrade dependencies -- Updated dependencies [1abc22f] - - @talend/babel-plugin-import-d3@0.4.1 - - @talend/scripts-config-cdn@10.11.1 - - @talend/module-to-cdn@9.10.1 - -## 11.1.1 - -### Patch Changes - -- Updated dependencies [9568363] - - @talend/babel-plugin-import-d3@0.4.0 - - @talend/scripts-config-cdn@10.11.0 - -## 11.1.0 - -### Minor Changes - -- 673984929: Add missing deps, remove dependency with scripts-core (circular dependency) and adapt code for PNPM - -### Patch Changes - -- f2ef85811: Update dependencies -- Updated dependencies [673984929] -- Updated dependencies [f2ef85811] -- Updated dependencies [673984929] - - @talend/babel-plugin-import-d3@0.3.0 - - @talend/scripts-config-cdn@10.9.0 - -## 11.0.1 - -### Patch Changes - -- b0193afbd: chore: upgrade webpack - -## 11.0.0 - -### Major Changes - -- 202b4daf2: Webpack major upgrade (4 to 5). - - ## Breaking changes - - @talend/bootstrap-theme is not imported anymore for you. You have to import it first in your project - - ```diff - +import '@talend/bootstrap-theme'; - ``` - - No more polyfills loaded for you. We have removed the folliwng packages: - - - `regenerator-runtime` - - `core-js-bundle` - -### Patch Changes - -- @talend/scripts-config-cdn@10.5.1 - -## 10.0.1 - -### Patch Changes - -- 3f4ad5e30: fix: url of repository in package.json -- Updated dependencies [3f4ad5e30] - - @talend/module-to-cdn@9.8.3 - - @talend/babel-plugin-import-d3@0.2.1 - -## 10.0.0 - -### Major Changes - -- b7d571c: Breaking change: remove private package supports from config-cdn - - You are pleased to move use private preset if you need to support private configs. - -### Patch Changes - -- Updated dependencies [b7d571c] - - @talend/scripts-config-cdn@10.0.0 - -## 9.7.6 - -### Patch Changes - -- 9cf2a86: chore(dependencies): auto update for maintenance purpose - - ```diff - - "@talend/module-to-cdn": "^9.7.5" - + "@talend/module-to-cdn": "^9.7.6" - ``` - -- 77af1fc: chore(dependencies): auto update for maintenance purpose - - ```diff - - "@talend/module-to-cdn": "^9.7.2" - + "@talend/module-to-cdn": "^9.7.5" - - "@talend/scripts-config-cdn": "^9.10.5" - + "@talend/scripts-config-cdn": "^9.11.2" - - "webpack-bundle-analyzer": "^4.4.2" - + "webpack-bundle-analyzer": "^4.5.0" - - "webpack-cli": "^4.8.0" - + "webpack-cli": "^4.9.2" - ``` - -- Updated dependencies [77af1fc] -- Updated dependencies [9cf2a86] - - @talend/scripts-config-cdn@9.11.3 - -## 9.7.5 - -### Patch Changes - -- 52527bd: upgrade webpack-cli - -## 9.7.4 - -### Patch Changes - -- a6201b3: Revert upgrade of webpack-cli and dev-server - -## 9.7.3 - -### Patch Changes - -- 3e942de: Remove axios from dependencies for security reasons -- Updated dependencies [3e942de] - - @talend/module-to-cdn@9.7.2 - -## 9.7.2 - -### Patch Changes - -- 9ef83c5: Upgrade dependencies to be aligned with what is used in dev mode -- Updated dependencies [9ef83c5] - - @talend/scripts-config-cdn@9.10.5 - - @talend/module-to-cdn@9.7.1 - -## 9.7.1 - -### Patch Changes - -- fe505ee: upgrade dependencies for security issues - -## 9.7.0 - -### Minor Changes - -- 9a051a3: Add support for NPM_TOKEN to be used to download private packages - -### Patch Changes - -- Updated dependencies [9a051a3] - - @talend/scripts-config-cdn@9.8.0 diff --git a/tools/scripts-build-cdn/README.md b/tools/scripts-build-cdn/README.md deleted file mode 100644 index fdb06b8ee79..00000000000 --- a/tools/scripts-build-cdn/README.md +++ /dev/null @@ -1,38 +0,0 @@ -# Build CDN scripts - -Let's download UMD files from https://unpkg.com and/or build your own custom UMDs! - - -## Getting started - -To use this CLI you just have to add `@talend/scripts-build-cdn` in your project. - -Once installed this package add the command `talend-cdn` to the node_modules/.bin folder. - -An example of usage is available at [github/Talend/cdn-content](https://github.com/Talend/cdn-content) - - -## Context - -You should not let your app rely on unpkg which is provided for free. As a company, you want to master your toolchain and your produced content. This script has been created for this reason: **build your own CDN**. - -Up to you to rely on whatever distribution network service like Netlify or CloudFlare or any other option. - -# How to use - -talend-cdn command accepts two subcommands: - -* download -* build - -Both have their options - -```bash -$> talend-cdn download -d -e ';@angular;' --versions ../../../ui/versions/dependencies.json -``` - -| command | option | default | description | -| -- | -- | -- | -- | -| download | -e --exclude | '' | exclude patterns from the global list | -| download | --versions | '' | path to a dependencies.json file containing the minimum version you want | -| download | -v --verbose | false | display more information in the output | diff --git a/tools/scripts-build-cdn/build.js b/tools/scripts-build-cdn/build.js deleted file mode 100755 index b6d6babb151..00000000000 --- a/tools/scripts-build-cdn/build.js +++ /dev/null @@ -1,216 +0,0 @@ -/** - * Goal of this script is to take a set of libraries and build their UMDs - */ -/* eslint-disable no-continue */ -/* eslint-disable no-plusplus */ -/* eslint-disable no-await-in-loop */ -/* eslint-disable no-param-reassign */ - -const moduleToCdn = require('@talend/module-to-cdn'); -const mkdirp = require('mkdirp'); -const cpx = require('cpx2'); -const { rimraf } = require('rimraf'); -const fs = require('fs'); -const util = require('util'); -const { exec } = require('child_process'); -const path = require('path'); -const getInfo = require('./getInfo'); - -const execProm = util.promisify(exec); -const rmProm = util.promisify(rimraf); -const cpProm = util.promisify(cpx.copy); - -const ROOT = 'dist'; -const TARGET = 'talend-umds'; - -async function cleanup(packagePath, version) { - try { - await rmProm(`${packagePath}/${version}/node_modules`); - await rmProm(`${packagePath}/${version}/package.json`); - await rmProm(`${packagePath}/${version}/package-lock.json`); - await rmProm(`${packagePath}/${version}/webpack.config.js`); - await rmProm(`${packagePath}/${version}/webpack.index.js`); - } catch (error) { - console.error(error); - } -} - -async function main(args) { - if (!fs.existsSync(ROOT)) { - mkdirp.sync(ROOT); - } - const { config, packages, getVersions, program } = getInfo(args); - - for (let index = 0; index < packages.length; index++) { - const importPath = packages[index]; - console.log('process', importPath); - - const versions = getVersions(importPath); - - for (let jindex = 0; jindex < versions.length; jindex++) { - const version = versions[jindex]; - if (version.includes('-')) { - continue; - } - const packageCdnConfig = moduleToCdn(importPath, version, { env: 'production' }); - const packageName = packageCdnConfig.name; - const UMDName = packageCdnConfig.var; - const packagePath = `${ROOT}/${packageName}`; - const packageJsonPath = `${packagePath}/${version}/package.json`; - const patchPath = `${__dirname}/patch/${packageName}/${version}`; - const UMDFileName = packageCdnConfig.path.replace(`/${TARGET}/`, ''); - - if (fs.existsSync(`${packagePath}/${version}/${TARGET}/${UMDFileName}`) && !program.force) { - await cleanup(packagePath, version); - continue; - } - - if (!fs.existsSync(`${packagePath}/${version}`)) { - mkdirp.sync(`${packagePath}/${version}`); - } - - const devDependencies = { - d3: '^6.5.0', // so we can support d3-x babel plugin - }; - - if (packageName.includes('react') || packageName.includes('rc-')) { - devDependencies.react = '^16.0.0'; - devDependencies['react-dom'] = '^16.0.0'; - } - - if (config[packageName].peerDependencies) { - Object.assign(devDependencies, config[packageName].peerDependencies); - } - - const pjson = { - name: `@talend/${UMDName}`, - devDependencies, - dependencies: { [packageName]: version }, - }; - - if (!fs.existsSync(packageJsonPath)) { - if (fs.existsSync(`${patchPath}/package.json`)) { - // eslint-disable-next-line no-await-in-loop - await cpProm(`${patchPath}/package.json`, packageJsonPath.replace('package.json', '')); - } else { - fs.writeFileSync(packageJsonPath, JSON.stringify(pjson, null, 2)); - } - } - - if (!fs.existsSync(`${packagePath}/${version}/webpack.config.js`)) { - fs.writeFileSync( - `${packagePath}/${version}/webpack.config.js`, - ` -const path = require('path'); -const cdn = require('@talend/scripts-config-cdn'); -const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; - -cdn.init(); - -module.exports = { - entry: path.resolve(__dirname, './webpack.index.js'), - mode: 'production', - optimization: { - minimize: true, - }, - devtool: 'source-map', - output: { - filename: '${UMDFileName}', - path: path.resolve(__dirname, '${TARGET}'), - library: '${UMDName}', - libraryTarget: 'umd', - globalObject: 'this', - }, - module: { - rules: [ - { - test: /\.js$/, - use: { - loader: require.resolve('babel-loader'), - options: { - plugins: ['@talend/babel-plugin-import-d3'] - } - }, - include: /(${packageName})/ - } - ], - }, - plugins: [ - new BundleAnalyzerPlugin({ - analyzerMode: 'static', - openAnalyzer: false, - logLevel: 'error', - reportFilename: '${UMDName}.min.js.report.html', - }), - cdn.getWebpackPlugin({}) - ], -}; - `, - ); - } - if (!fs.existsSync(`${packagePath}/${version}/webpack.index.js`)) { - fs.writeFileSync( - `${packagePath}/${version}/webpack.index.js`, - `export { default } from '${packageName}'; - export * from '${packageName}'; - `, - ); - } - - console.log(`npm i ${packageName} ${version}`); - try { - await execProm('npm i', { cwd: path.resolve(`./${packagePath}/${version}`) }); - } catch (error) { - console.error(error); - return; - } - const info = require( - `${process.cwd()}/${packagePath}/${version}/node_modules/${packageName}/package.json`, - ); - if (info.peerDependencies) { - pjson.devDependencies = Object.keys(info.peerDependencies).reduce((acc, key) => { - acc[key] = info.peerDependencies[key]; - return acc; - }, pjson.devDependencies || {}); - fs.writeFileSync(`${packagePath}/${version}/package.json`, JSON.stringify(pjson, null, 2)); - try { - await execProm('npm i', { cwd: path.resolve(`./${packagePath}/${version}`) }); - } catch (error) { - console.error(error); - } - } - - if (program.webpack) { - console.log('webpack umd'); - try { - await execProm(`webpack --config ./${packagePath}/${version}/webpack.config.js`); - } catch (error) { - console.error(error); - return; - } - } - if (program.copy && packageCdnConfig.path) { - let dirName = `${path.dirname(packageCdnConfig.path)}/`; - if (dirName === '//') { - dirName = '/'; - } - console.log('copy content from', dirName); - try { - await cpProm( - `./${packagePath}/${version}/node_modules/${packageName}${dirName}**/*.{js,png,jpg,jpeg,json,css,woff,woff2,svg}`, - `./${packagePath}/${version}${dirName}`, - { preserve: true }, - ); - } catch (error) { - console.error(error); - return; - } - } - - console.log('cleanup'); - await cleanup(packagePath, version); - } - } -} - -module.exports = main; diff --git a/tools/scripts-build-cdn/clean.js b/tools/scripts-build-cdn/clean.js deleted file mode 100644 index 60a2f78f35a..00000000000 --- a/tools/scripts-build-cdn/clean.js +++ /dev/null @@ -1,40 +0,0 @@ -/* eslint-disable no-plusplus */ -const { rimrafSync } = require('rimraf'); - -const CWD = process.cwd(); -const DIST = 'dist'; -const PATHS = [ - `${CWD}/${DIST}/**/*.scss`, - `${CWD}/${DIST}/**/node_modules`, - `${CWD}/${DIST}/**/coverage`, - `${CWD}/${DIST}/**/lcov-report`, - `${CWD}/${DIST}/**/tests/`, - `${CWD}/${DIST}/*/*/src`, - `${CWD}/${DIST}/**/package.json`, - `${CWD}/${DIST}/**/*.d.ts`, - `${CWD}/${DIST}/**/*.ls`, - `${CWD}/${DIST}/**/*.gzip`, - `${CWD}/${DIST}/**/bower.json`, - `${CWD}/${DIST}/**/*.md`, - `${CWD}/${DIST}/**/*.tgz`, - `${CWD}/${DIST}/**/LICENSE`, - `${CWD}/${DIST}/**/package-lock.json`, - `${CWD}/${DIST}/**/.idea`, - `${CWD}/${DIST}/**/yarn.lock`, - `${CWD}/${DIST}/**/webpack*.js`, - `${CWD}/${DIST}/*/*/package`, -]; - -module.exports = function cleanup(program) { - function log(...msg) { - if (program.verbose) { - console.log(...msg); - } - } - - for (let index = 0; index < PATHS.length; index++) { - const path = PATHS[index]; - log(`rm -rf ${path}`); - rimrafSync(path); - } -}; diff --git a/tools/scripts-build-cdn/download.js b/tools/scripts-build-cdn/download.js deleted file mode 100644 index dd71a27ebf6..00000000000 --- a/tools/scripts-build-cdn/download.js +++ /dev/null @@ -1,151 +0,0 @@ -/* eslint-disable no-continue */ -/* eslint-disable no-plusplus */ -/* eslint-disable no-await-in-loop */ -/* eslint-disable no-param-reassign */ - -const fs = require('fs'); -const moduleToCdn = require('@talend/module-to-cdn'); -const util = require('util'); -const path = require('path'); -const { exec } = require('child_process'); -const mkdirp = require('mkdirp'); -const globalCleanup = require('./clean'); -const getInfo = require('./getInfo'); - -function isScopedPackageName(packageName) { - return packageName.startsWith('@'); -} -const execProm = util.promisify(exec); - -const CWD = process.cwd(); -const DIST = 'dist'; - -async function cleanup(moduleName, version) { - await execProm(`rm ${CWD}/${DIST}/${moduleName}/${version}.tgz`); - await execProm(`rm -rf ${CWD}/${DIST}/${moduleName}/package`); -} - -async function download(args) { - const { packages, getVersions, program } = getInfo(args); - - console.log('Starting...'); - const promises = []; - - for (let jindex = 0; jindex < packages.length; jindex++) { - const importPath = packages[jindex]; - const moduleName = moduleToCdn.getModuleName(importPath); - const downloadVersions = getVersions(importPath); - if (!program.package && !program.from) { - let cmd = `talend-cdn download -p ${moduleName}`; - if (program.force) { - cmd += ' -f'; - } - if (args.verbose) { - cmd += ' -v'; - console.log('trigger', cmd); - } - if (args.exclude) { - cmd += ` --exclude "${args.exclude}"`; - } - if (args.versions) { - cmd += ` --versions "${args.versions}"`; - } - if (args.umd) { - cmd += ` --umd "${args.umd}"`; - } - - const prom = execProm(cmd, { - cwd: process.cwd(), - }).then(({ stdout, stderr }) => { - if (stderr) { - console.error('ERROR', stderr); - } - if (stdout && program.verbose) { - console.log(stdout); - } - }); - promises.push(prom); - continue; - } - console.log('importPath', importPath); - - for (let index = 0; index < downloadVersions.length; index++) { - const version = downloadVersions[index]; - const cdnConfig = moduleToCdn(importPath, version, { env: 'production' }); - - if (!cdnConfig.path && program.verbose) { - console.error('❌ no url found for', moduleName, version); - continue; - } - if (cdnConfig.url.includes('/talend-umds/')) { - // custom build - continue; - } - if (fs.existsSync(`${CWD}/${DIST}/${moduleName}/${version}${cdnConfig.path}`)) { - if (program.force) { - try { - await execProm(`rm -rf ${CWD}/${DIST}/${moduleName}/${version}`, { - cwd: process.cwd(), - }); - } catch (e) { - console.error(e); - } - } else { - continue; - } - } - const tarballName = isScopedPackageName(moduleName) ? moduleName.split('/')[1] : moduleName; - - const url = `https://registry.npmjs.org/${moduleName}/-/${tarballName}-${version}.tgz`; - if (!fs.existsSync(`${CWD}/${DIST}/${moduleName}`)) { - mkdirp.sync(`${CWD}/${DIST}/${moduleName}`); - } - console.log(`curl ${url}`); - let curlOpts = ''; - if (process.env.NPM_TOKEN) { - curlOpts = `-H "Authorization: Bearer ${process.env.NPM_TOKEN}"`; - } - try { - await execProm(`curl ${curlOpts} ${url} > dist/${moduleName}/${version}.tgz`, { - cwd: process.cwd(), - }); - if (program.verbose) { - console.log('downloaded'); - } - } catch (e) { - console.error(e); - } - if (program.verbose) { - console.log(`tar ${url}`); - } - try { - await execProm(`tar -xf ${version}.tgz`, { cwd: `${CWD}/${DIST}/${moduleName}` }); - const folder = path.dirname(cdnConfig.path); - const parent = folder === '/' ? '' : '/..'; - await execProm(`mkdir -p ${version}${folder}`, { cwd: `${CWD}/${DIST}/${moduleName}` }); - - await execProm(`cp -R package${folder}* ${version}${folder}${parent}`, { - cwd: `${CWD}/${DIST}/${moduleName}`, - }); - if (program.verbose) { - console.log('extracted'); - } - } catch (e) { - console.error(url, e); - } - try { - await cleanup(moduleName, version, cdnConfig); - } catch (e) { - console.error(e); - } - } - } - if (promises.length > 0) { - await Promise.all(promises).catch(e => console.error(e)); - } - if (args.cleanup) { - await globalCleanup(args); - } -} - -module.exports = download; diff --git a/tools/scripts-build-cdn/getInfo.js b/tools/scripts-build-cdn/getInfo.js deleted file mode 100644 index 555803556c1..00000000000 --- a/tools/scripts-build-cdn/getInfo.js +++ /dev/null @@ -1,145 +0,0 @@ -const moduleToCdn = require('@talend/module-to-cdn'); -const fs = require('fs'); -const semver = require('semver'); - -function getConfigFromLocalFile() { - const configPath = `${process.cwd()}/talend-cdn.json`; - if (fs.existsSync(configPath)) { - return require(configPath); - } - return {}; -} - -function getPackageInfo(slug) { - const info = {}; - const splitted = slug.split('@'); - const isScoped = slug.startsWith('@'); - if (isScoped && splitted.length > 2) { - info.version = [splitted[2]]; - info.name = `@${splitted[1]}`; - } else if (!isScoped && splitted.length > 1) { - info.version = splitted[1]; - info.name = splitted[0]; - } else { - info.name = slug; - } - return info; -} - -function getInfo(args) { - let config = moduleToCdn.getAllModules(); - const localConfig = getConfigFromLocalFile(); - const program = { ...localConfig, ...args }; - - let customVersion; - let customPackage; - if (program.umd) { - config = require(`${process.cwd()}/${program.umd}`); - if (program.verbose) { - console.log('umd file found and injected into module-to-cdn'); - } - moduleToCdn.add(config); - } - function include(m) { - if (program.exclude) { - if (program.exclude.includes(`;${m};`)) { - return false; - } - - if (m.startsWith('@') && program.exclude.includes(`;${m.split('/')[0]};`)) { - return false; - } - } - - return true; - } - /** - * Fill versions form a JSON files used to align multiple projects - * The fill may be passed as argument - */ - let VERSIONS = {}; - if (program.versions) { - const versionPath = `${process.cwd()}/${program.versions}`; - if (fs.existsSync(versionPath)) { - if (program.verbose) { - console.log(`versions file found and used ${program.versions}`); - } - VERSIONS = require(versionPath); - // replace version number by a constraint - Object.keys(VERSIONS).reduce((acc, key) => { - acc[key] = `>= ${VERSIONS[key].replace('^', '')}`; - return acc; - }, VERSIONS); - } else { - console.error('Error: you have passed an invalid path to set the versions limit.'); - } - } - - let packages = Object.keys(config).filter(m => include(m)); - if (program.from) { - if (program.verbose) { - console.log(`start from ${program.from}`); - } - const info = getPackageInfo(program.from); - customVersion = info.version; - customPackage = info.name; - const index = packages.indexOf(info.name); - packages = packages.slice(index); - } - - if (program.package) { - if (program.verbose) { - console.log(`filter on ${program.package}`); - } - const info = getPackageInfo(program.package); - customVersion = info.version; - customPackage = info.name; - packages = [info.name]; - } - if (program.verbose) { - console.log(`found ${packages.length} packages`); - } - function getMatchedVersion(all, globalConstraint = '>= 0.0.0', moduleName) { - return function filter(range) { - return all - .filter(version => { - if (customVersion && moduleName === customPackage) { - if (program.package) { - return version === customVersion; - } - return semver.satisfies(version, `>= ${customVersion}`); - } - if (VERSIONS[moduleName]) { - return semver.satisfies(version, VERSIONS[moduleName]); - } - return true; - }) - .filter(version => semver.satisfies(version, globalConstraint)) - .filter(version => semver.satisfies(version, range)); - }; - } - function isPrerelease(v) { - // FIXME: remove this code ASAP. it is to support UMD alpha release of UI - return semver.parse(v).prerelease.length > 0; - } - function getVersions(importPath) { - const moduleName = moduleToCdn.getModuleName(importPath); - const versionRanges = Object.keys(config[importPath].versions); - const allVersions = moduleToCdn.cache.getAllVersions(moduleName).filter(v => !isPrerelease(v)); - const filteredVersions = [].concat( - ...versionRanges.map(getMatchedVersion(allVersions, undefined, moduleName)), - ); - if (program.verbose) { - console.log(`${filteredVersions.length} versions of ${moduleName}`); - } - return filteredVersions; - } - return { - program, - packages, - config, - getVersions, - }; -} - -module.exports = getInfo; diff --git a/tools/scripts-build-cdn/index.js b/tools/scripts-build-cdn/index.js deleted file mode 100755 index 096c8925d4d..00000000000 --- a/tools/scripts-build-cdn/index.js +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env node -/** - * This script is useful if you want to maintain a CDN. - */ - -const { program } = require('commander'); -const download = require('./download'); -const build = require('./build'); -const clean = require('./clean'); - -program.command('cleanup').option('-v, --verbose', 'output extra debugging').action(clean); - -program - .command('download') - // filter over packages - .option('--from ', 'exclude modules in the global list until the provided module') - .option('--exclude ', 'exclude modules based on name and scope name') - .option('-p, --package ', 'filter one package') - .option('--versions ', 'path to the file versions') - .option('-u, --umd ', 'path to umd file') - // global behavior - .option('-v, --verbose', 'output extra debugging') - // specific - .option('-f, --force', 'force re download') - .option('--cleanup', 'trigger cleanup subcommand at the end') - .action(download); -program - .command('build') - // filter over packages - .option('--from ', 'exclude modules in the global list until the provided module') - .option('--exclude ', 'exclude modules based on name and scope name') - .option('-p, --package ', 'filter one package') - .option('-u, --umd ', 'path to umd file') - // global behavior - .option('-v, --verbose', 'output extra debugging') - // specific - .option('-f, --force', 'force full rebuild when output already exists') - .option('-c, --copy', 'copy content of package') - .option('-w, --webpack', 'build UMD using webpack') - .action(build); - -program.parse(process.argv); diff --git a/tools/scripts-build-cdn/package.json b/tools/scripts-build-cdn/package.json deleted file mode 100644 index 46b3dedfcbc..00000000000 --- a/tools/scripts-build-cdn/package.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "name": "@talend/scripts-build-cdn", - "version": "11.2.0", - "description": "Give a CLI to build a CDN for js and css with unpkg like structures", - "main": "index.js", - "bin": { - "talend-cdn": "./index.js" - }, - "scripts": { - "lint": "eslint ./", - "start": "node index.js --debug --exclude ';@angular;' 2> error.log", - "test": "echo \"Nothing to test\"" - }, - "repository": { - "type": "git", - "url": "github.com/Talend/ui" - }, - "keywords": [ - "talend" - ], - "author": "Talend Frontend (http://www.talend.com)", - "license": "Apache-2.0", - "dependencies": { - "@talend/babel-plugin-import-d3": "^0.5.0", - "@talend/module-to-cdn": "^9.11.0", - "@talend/scripts-config-cdn": "^10.12.0", - "@yarnpkg/lockfile": "^1.1.0", - "commander": "^6.2.1", - "cpx2": "^3.0.2", - "execa": "^4.1.0", - "mkdirp": "^1.0.4", - "queue": "^6.0.2", - "rimraf": "^5.0.7", - "semver": "^7.6.2", - "webpack": "^5.92.0", - "webpack-bundle-analyzer": "^4.10.2", - "webpack-cli": "^4.10.0" - }, - "devDependencies": { - "@talend/eslint-config": "^13.2.0", - "@talend/eslint-plugin": "^1.3.0" - }, - "publishConfig": { - "access": "public" - } -} diff --git a/tools/scripts-build-cdn/patch/@popperjs/core/2.5.0/package.json b/tools/scripts-build-cdn/patch/@popperjs/core/2.5.0/package.json deleted file mode 100644 index 22b8615b002..00000000000 --- a/tools/scripts-build-cdn/patch/@popperjs/core/2.5.0/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "@talend/popper-core", - "devDependencies": { - "patch-package": "^6.2.2" - }, - "dependencies": { - "@popperjs/core": "2.5.0" - } -}