Skip to content

Commit

Permalink
Add dependencies syncronizer utility
Browse files Browse the repository at this point in the history
  • Loading branch information
sneridagh committed Mar 14, 2024
1 parent b21b016 commit 26e6725
Show file tree
Hide file tree
Showing 6 changed files with 1,623 additions and 3,981 deletions.
103 changes: 79 additions & 24 deletions apps/plone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
"@plone/registry": "workspace:*",
"@plone/volto": "workspace:*",
"@plone/volto-slate": "workspace:*",
"@redux-devtools/extension": "^3.3.0",
"classnames": "2.2.6",
"connected-react-router": "6.8.0",
"debug": "4.3.2",
Expand All @@ -167,7 +168,7 @@
"prop-types": "15.7.2",
"query-string": "7.1.0",
"rc-time-picker": "3.7.3",
"react": "17.0.2",
"react": "18.2.0",
"react-anchor-link-smooth-scroll": "1.0.12",
"react-animate-height": "2.0.17",
"react-beautiful-dnd": "13.0.0",
Expand All @@ -176,40 +177,38 @@
"react-detect-click-outside": "1.1.1",
"react-dnd": "5.0.0",
"react-dnd-html5-backend": "5.0.1",
"react-dom": "17.0.2",
"react-dom": "18.2.0",
"react-dropzone": "11.1.0",
"react-fast-compare": "2.0.4",
"react-image-gallery": "1.2.7",
"react-intersection-observer": "9.1.0",
"react-intl": "3.8.0",
"react-intl-redux": "2.2.0",
"react-intl-redux": "2.3.0",
"react-medium-image-zoom": "3.0.15",
"react-portal": "4.2.1",
"react-redux": "7.2.4",
"react-redux": "8.1.2",
"react-router": "5.2.0",
"react-router-config": "5.1.1",
"react-router-dom": "5.2.0",
"react-router-hash-link": "2.4.3",
"react-select": "4.3.1",
"react-select-async-paginate": "0.5.3",
"react-share": "2.3.1",
"react-side-effect": "2.1.0",
"react-side-effect": "2.1.2",
"react-simple-code-editor": "0.7.1",
"react-sortable-hoc": "2.0.0",
"react-test-renderer": "17.0.2",
"react-toastify": "5.4.1",
"react-test-renderer": "18.2.0",
"react-toastify": "5.5.0",
"react-transition-group": "4.4.5",
"react-virtualized": "9.22.3",
"redux": "4.1.0",
"redux-actions": "2.6.5",
"redux": "4.2.1",
"redux-actions": "3.0.0",
"redux-connect": "10.0.0",
"@redux-devtools/extension": "^3.3.0",
"redux-localstorage-simple": "2.3.1",
"redux-localstorage-simple": "2.5.1",
"redux-mock-store": "1.5.4",
"redux-thunk": "2.3.0",
"redux-thunk": "2.4.2",
"rrule": "2.7.1",
"semantic-ui-less": "2.4.1",
"semantic-ui-react": "2.0.3",
"semantic-ui-react": "2.1.5",
"serialize-javascript": "3.1.0",
"slate": "0.100.0",
"slate-hyperscript": "0.100.0",
Expand All @@ -224,31 +223,60 @@
"volto-volto-project": "workspace:*"
},
"devDependencies": {
"@babel/core": "^7.0.0",
"@babel/eslint-parser": "7.22.15",
"@babel/plugin-proposal-export-default-from": "7.18.10",
"@babel/plugin-proposal-export-namespace-from": "7.18.9",
"@babel/plugin-proposal-json-strings": "7.18.6",
"@babel/plugin-proposal-nullish-coalescing-operator": "7.18.6",
"@babel/plugin-proposal-throw-expressions": "7.18.6",
"@babel/plugin-syntax-export-namespace-from": "7.8.3",
"@babel/runtime": "7.20.6",
"@babel/types": "7.20.5",
"@jest/globals": "^29.7.0",
"@loadable/babel-plugin": "5.13.2",
"@loadable/webpack-plugin": "5.15.2",
"@plone/scripts": "workspace:*",
"@storybook/addon-actions": "^6.3.0",
"@storybook/addon-controls": "6.3.0",
"@storybook/addon-essentials": "^6.3.0",
"@storybook/addon-links": "^6.3.0",
"@plone/types": "workspace:*",
"@plone/volto-coresandbox": "workspace:*",
"@sinonjs/fake-timers": "^6.0.1",
"@storybook/addon-actions": "^6.5.15",
"@storybook/addon-controls": "6.5.15",
"@storybook/addon-docs": "^6.5.15",
"@storybook/addon-essentials": "^6.5.15",
"@storybook/addon-links": "^6.5.15",
"@storybook/builder-webpack5": "^6.5.15",
"@storybook/manager-webpack5": "^6.5.15",
"@storybook/react": "^6.3.0",
"@typescript-eslint/eslint-plugin": "6.7.0",
"@typescript-eslint/parser": "6.7.0",
"@storybook/react": "^6.5.15",
"@testing-library/cypress": "10.0.1",
"@testing-library/jest-dom": "6.4.2",
"@testing-library/react": "14.2.0",
"@testing-library/react-hooks": "8.0.1",
"@types/jest": "^29.5.8",
"@types/lodash": "^4.14.201",
"@types/react": "^18",
"@types/react-dom": "^18",
"@types/react-router-dom": "^5.3.3",
"@types/react-test-renderer": "18.0.7",
"@types/uuid": "^9.0.2",
"@typescript-eslint/eslint-plugin": "7.1.1",
"@typescript-eslint/parser": "7.1.1",
"autoprefixer": "10.4.8",
"axe-core": "4.4.2",
"babel-loader": "9.1.0",
"babel-plugin-add-module-exports": "0.2.1",
"babel-plugin-lodash": "3.3.4",
"babel-plugin-react-intl": "5.1.17",
"babel-plugin-root-import": "6.1.0",
"babel-preset-razzle": "4.2.18",
"bundlewatch": "0.3.3",
"circular-dependency-plugin": "5.2.2",
"css-loader": "5.2.7",
"eslint": "^8.57.0",
"cypress": "13.6.6",
"cypress-axe": "1.5.0",
"cypress-file-upload": "5.0.8",
"deep-freeze": "0.0.1",
"eslint": "8.49.0",
"eslint-config-prettier": "9.1.0",
"eslint-config-react-app": "7.0.1",
"eslint-import-resolver-alias": "1.1.2",
Expand All @@ -258,10 +286,21 @@
"eslint-plugin-prettier": "5.1.3",
"eslint-plugin-react": "7.33.2",
"eslint-plugin-react-hooks": "4.6.0",
"full-icu": "1.4.0",
"glob": "7.1.6",
"html-webpack-plugin": "5.5.0",
"identity-obj-proxy": "3.0.0",
"jest": "26.6.3",
"jest-environment-jsdom": "^26",
"jest-file": "1.0.0",
"jest-junit": "8.0.0",
"jsdom": "^16.7.0",
"jsonwebtoken": "9.0.0",
"less": "3.11.1",
"less-loader": "11.1.0",
"lodash-webpack-plugin": "0.11.6",
"mini-css-extract-plugin": "2.7.2",
"moment-locales-webpack-plugin": "1.2.0",
"mrs-developer": "^2.1.1",
"postcss": "8.4.31",
"postcss-flexbugs-fixes": "5.0.2",
Expand All @@ -272,17 +311,33 @@
"postcss-scss": "4.0.6",
"prettier": "3.2.5",
"razzle": "4.2.18",
"razzle-dev-utils": "4.2.18",
"razzle-plugin-scss": "4.2.18",
"react-docgen-typescript-plugin": "^1.0.5",
"react-error-overlay": "6.0.9",
"react-is": "^18.2.0",
"release-it": "^17.1.1",
"semver": "^7.5.4",
"start-server-and-test": "1.14.0",
"style-loader": "3.3.1",
"stylelint": "^16.2.1",
"stylelint": "16.2.1",
"stylelint-config-idiomatic-order": "10.0.0",
"stylelint-prettier": "5.0.0",
"svg-loader": "0.0.2",
"svgo-loader": "3.0.3",
"terser-webpack-plugin": "5.3.6",
"tmp": "0.2.1",
"ts-jest": "^26.4.2",
"ts-loader": "9.4.4",
"tsconfig": "*",
"typescript": "5.2.2"
"typescript": "5.2.2",
"use-trace-update": "1.3.2",
"wait-on": "6.0.0",
"webpack": "5.76.1",
"webpack-bundle-analyzer": "4.10.1",
"webpack-dev-server": "4.11.1",
"webpack-node-externals": "3.0.0",
"why": "0.6.2"
},
"theme": "volto-volto-project"
}
61 changes: 0 additions & 61 deletions packages/scripts/depsSync.js

This file was deleted.

90 changes: 90 additions & 0 deletions packages/scripts/deps_sync.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/usr/bin/env node
/* eslint no-console: 0 */
import fs from 'fs';
import https from 'https';

// if (process.argv.length < 3) {
// console.log(process.argv.length);
// process.exit(1);
// }

function loadPackageJSON(path = '.') {
return JSON.parse(fs.readFileSync(`${path}/package.json`, 'utf8'));
}

async function getVoltoPackageJSON(tag) {
const url = `https://raw.githubusercontent.com/plone/volto/${tag}/package.json`;
const requestContent = await new Promise((resolve, reject) => {
https
.get(url, {}, (resp) => {
let data = '';
resp.on('data', (chunk) => {
data += chunk;
});
resp.on('end', () => {
resolve(data);
});
})
.on('error', (err) => {
reject(err);
});
});
return JSON.parse(requestContent);
}

function updatePackageJSON(path = '.', packageJSON) {
// Sort the keys of the devDependencies object
const orderedDevDependencies = Object.keys(packageJSON.devDependencies)
.sort()
.reduce((obj, key) => {
obj[key] = packageJSON.devDependencies[key];
return obj;
}, {});

// Replace the devDependencies with the ordered version
packageJSON.devDependencies = orderedDevDependencies;

fs.writeFileSync(
`${path}/package.json`,
`${JSON.stringify(packageJSON, null, 2)}`,
);
}

async function main() {
const path = process.argv[2];
console.log(path);
const packageJSON = loadPackageJSON(path);
const currentVoltoVersion = packageJSON.dependencies['@plone/volto'];
let voltoPackageJSON;
if (currentVoltoVersion === 'workspace:*') {
voltoPackageJSON = loadPackageJSON('packages/volto');
} else {
voltoPackageJSON = await getVoltoPackageJSON(currentVoltoVersion);
}

const VoltoDependencies = voltoPackageJSON.dependencies;
const VoltoDevDependencies = voltoPackageJSON.devDependencies;

Object.entries(VoltoDevDependencies).forEach(([pkg, version]) => {
// console.log(`${pkg} @ ${version}`);
if (packageJSON.devDependencies[pkg]) {
packageJSON.devDependencies[pkg] = version;
console.log(`Updated devDependency on ${pkg} to version ${version}`);
} else {
packageJSON.devDependencies[pkg] = version;
console.log(`Added devDependency on ${pkg} to version ${version}`);
}
});

Object.entries(VoltoDependencies).forEach(([pkg, version]) => {
// console.log(`${pkg} @ ${version}`);
if (packageJSON.dependencies[pkg]) {
packageJSON.dependencies[pkg] = version;
console.log(`Updated dependency on ${pkg} to version ${version}`);
}
});

updatePackageJSON(path, packageJSON);
}

main();
3 changes: 2 additions & 1 deletion packages/scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"bin": {
"addon": "./addon/index.js",
"changelogupdater": "./changelogupdater.cjs",
"i18n": "./i18n.cjs"
"i18n": "./i18n.cjs",
"depssync": "./deps_sync.js"
},
"publishConfig": {
"access": "public"
Expand Down
Loading

0 comments on commit 26e6725

Please sign in to comment.