2
0
mirror of https://github.com/iconify/iconify.git synced 2024-12-13 14:13:06 +00:00

Update Lerna, remove old update script

This commit is contained in:
Vjacheslav Trushkin 2022-01-27 09:35:49 +02:00
parent 164708c9f8
commit f18342a98c
4 changed files with 6189 additions and 10216 deletions

15970
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -14,10 +14,9 @@
"bootstrap": "lerna bootstrap --force-local",
"clean": "lerna clean",
"link": "lerna link --force-local",
"setup": "npm run clean && npm run bootstrap",
"update": "node update-deps --all --update"
"setup": "npm run clean && npm run bootstrap"
},
"devDependencies": {
"lerna": "^3.22.1"
"lerna": "^4.0.0"
}
}

View File

@ -14,7 +14,6 @@
},
"devDependencies": {
"@iconify-icons/mdi-light": "^1.1.1",
"@iconify/svelte": "^2.1.2",
"@sveltejs/kit": "next",
"@types/cookie": "^0.4.1",
"svelte": "^3.46.2",
@ -35,18 +34,6 @@
"integrity": "sha512-jcc2WKucqUjJSiP4f1eRehD455ohLVJkwEGR43/VpxHLXjEoLkQDZ+PIS+Sf3X/pJ77DGWPo94417OXarxJNPw==",
"dev": true
},
"node_modules/@iconify/svelte": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/@iconify/svelte/-/svelte-2.1.2.tgz",
"integrity": "sha512-NvWPg/lKNDlzyB698vLv8hYT5eRDxSIk0QnMtB7UMOZ7/SbmInyBqsb8t3SXoCYVsNG3poznW+pwYrJZ7kY+mQ==",
"dev": true,
"dependencies": {
"cross-fetch": "^3.1.5"
},
"funding": {
"url": "http://github.com/sponsors/cyberalien"
}
},
"node_modules/@lukeed/csprng": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@lukeed/csprng/-/csprng-1.0.0.tgz",
@ -290,15 +277,6 @@
"node": ">= 0.6"
}
},
"node_modules/cross-fetch": {
"version": "3.1.5",
"resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.5.tgz",
"integrity": "sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw==",
"dev": true,
"dependencies": {
"node-fetch": "2.6.7"
}
},
"node_modules/debug": {
"version": "4.3.3",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz",
@ -892,26 +870,6 @@
"node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
}
},
"node_modules/node-fetch": {
"version": "2.6.7",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
"integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==",
"dev": true,
"dependencies": {
"whatwg-url": "^5.0.0"
},
"engines": {
"node": "4.x || >=6.0.0"
},
"peerDependencies": {
"encoding": "^0.1.0"
},
"peerDependenciesMeta": {
"encoding": {
"optional": true
}
}
},
"node_modules/normalize-path": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
@ -1317,12 +1275,6 @@
"node": ">=8.0"
}
},
"node_modules/tr46": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
"integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=",
"dev": true
},
"node_modules/tslib": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
@ -1379,22 +1331,6 @@
}
}
},
"node_modules/webidl-conversions": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
"integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=",
"dev": true
},
"node_modules/whatwg-url": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
"integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=",
"dev": true,
"dependencies": {
"tr46": "~0.0.3",
"webidl-conversions": "^3.0.0"
}
},
"node_modules/wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
@ -1414,15 +1350,6 @@
"integrity": "sha512-jcc2WKucqUjJSiP4f1eRehD455ohLVJkwEGR43/VpxHLXjEoLkQDZ+PIS+Sf3X/pJ77DGWPo94417OXarxJNPw==",
"dev": true
},
"@iconify/svelte": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/@iconify/svelte/-/svelte-2.1.2.tgz",
"integrity": "sha512-NvWPg/lKNDlzyB698vLv8hYT5eRDxSIk0QnMtB7UMOZ7/SbmInyBqsb8t3SXoCYVsNG3poznW+pwYrJZ7kY+mQ==",
"dev": true,
"requires": {
"cross-fetch": "^3.1.5"
}
},
"@lukeed/csprng": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@lukeed/csprng/-/csprng-1.0.0.tgz",
@ -1603,15 +1530,6 @@
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.1.tgz",
"integrity": "sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA=="
},
"cross-fetch": {
"version": "3.1.5",
"resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.5.tgz",
"integrity": "sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw==",
"dev": true,
"requires": {
"node-fetch": "2.6.7"
}
},
"debug": {
"version": "4.3.3",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz",
@ -2015,15 +1933,6 @@
"integrity": "sha512-zJpuPDwOv8D2zq2WRoMe1HsfZthVewpel9CAvTfc/2mBD1uUT/agc5f7GHGWXlYkFvi1mVxe4IjvP2HNrop7nQ==",
"dev": true
},
"node-fetch": {
"version": "2.6.7",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
"integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==",
"dev": true,
"requires": {
"whatwg-url": "^5.0.0"
}
},
"normalize-path": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
@ -2267,12 +2176,6 @@
"is-number": "^7.0.0"
}
},
"tr46": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
"integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=",
"dev": true
},
"tslib": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
@ -2298,22 +2201,6 @@
"rollup": "^2.59.0"
}
},
"webidl-conversions": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
"integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=",
"dev": true
},
"whatwg-url": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
"integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=",
"dev": true,
"requires": {
"tr46": "~0.0.3",
"webidl-conversions": "^3.0.0"
}
},
"wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",

View File

@ -1,305 +0,0 @@
const fs = require('fs');
const child_process = require('child_process');
// Directory where packages are
const packagesDir = __dirname + '/packages';
// package.json keys and install commands to install @latest versions of those dependencies
const packagesInstallList = [
{
prop: 'dependencies',
cmd: '--save',
},
{
prop: 'devDependencies',
cmd: '--save-dev',
},
];
// Packages to ignore for @latest install when peerDependency is detected
const ignorePeers = {
react: ['react', 'react-dom', 'react-test-renderer', '@types/react'],
vue: ['vue'],
};
// Ignore bugged modules
function canInstall(name, currentPackage) {
/*
// Due to a bug in rollup 2.x, rollup and its modules could not be updated. Fixed in 2.26.8!
if (name.split('-').shift() === 'rollup') {
return false;
}
if (name.split('/').shift() === '@rollup') {
return false;
}
*/
return true;
}
// Tag to use for installing package
function getTag(name, currentPackage, currentVersion) {
const parts = currentPackage.split('-');
const currentPackage1 = parts.shift();
switch (name) {
case 'vue':
switch (currentPackage1) {
case '@iconify/vue':
return '@next';
case '@iconify/vue2':
return '@2';
default:
return null;
}
case 'vue-jest':
switch (currentPackage1) {
case '@iconify/vue':
return '@next';
case '@iconify/vue2':
return '@3';
default:
return null;
}
case '@vue/test-utils':
switch (currentPackage1) {
case '@iconify/vue':
return '@next';
case '@iconify/vue2':
return '@1';
default:
return null;
}
}
// Do not change major version for Vue 2 packages
if (currentPackage1 === '@iconify/vue2') {
const parts = currentVersion.split('.');
return '@' + parts.shift();
}
return '@latest';
}
// Update modes
const modes = {
// Standard update, matching existing version requirements
update: false,
// Installs @latest version of dependency, might cause issues, so test code after update
install: false,
};
// Get list of all packages
const localPackagesMap = Object.create(null);
fs.readdirSync(packagesDir).forEach((file) => {
try {
const data = JSON.parse(
fs.readFileSync(`${packagesDir}/${file}/package.json`, 'utf8')
);
if (typeof data.name === 'string') {
localPackagesMap[data.name] = file;
}
} catch (err) {
// console.error(err);
}
});
const localPackages = Object.keys(localPackagesMap);
const localDirs = Object.values(localPackagesMap);
console.log('Local packages:');
console.log(
localPackages
.map((name) => '\t' + localPackagesMap[name] + ': ' + name)
.join('\n')
);
// Get list of directories to parse
const parseDirs = [];
process.argv.slice(2).forEach((cmd) => {
if (cmd.slice(0, 2) === '--') {
// --all
if (cmd === '--all') {
localDirs.forEach(addDirToParse);
return;
}
// Command: --install or --update
const key = cmd.slice(2);
if (modes[key] !== void 0) {
modes[key] = true;
return;
}
invalidParam(cmd);
}
if (cmd.slice(0, 1) === '-') {
invalidParam(cmd);
}
// By package name: update-deps @iconify/core
if (localPackagesMap[cmd] !== void 0) {
addDirToParse(localPackagesMap[cmd]);
return;
}
// By directory name: update-deps core
if (localDirs.indexOf(cmd) !== -1) {
addDirToParse(cmd);
return;
}
invalidParam(cmd);
});
if (!parseDirs.length) {
usage();
return;
}
if (!modes.install) {
modes.update = true;
}
next();
/**
* Parse next directory
*/
function next() {
const dir = parseDirs.shift();
if (dir === void 0) {
return;
}
parse();
process.nextTick(next);
function parse() {
// Update dependencies
if (modes.update) {
update(dir);
}
// Install @latest versions of everything
if (!modes.install) {
return;
}
// Get package.json
const packageJSON = JSON.parse(
fs.readFileSync(packagesDir + '/' + dir + '/package.json', 'utf8')
);
const packageName = packageJSON.name;
// Get list of packages to ignore
let ignoreList = localPackages.slice(0);
if (packageJSON.peerDependencies !== void 0) {
Object.keys(packageJSON.peerDependencies).forEach((peer) => {
if (ignorePeers[peer] === void 0) {
throw new Error(
`Unknown peer dependency "${peer}" in ${dir}`
);
}
ignoreList = ignoreList.concat(ignorePeers[peer]);
});
}
// Get dependencies
packagesInstallList.forEach((item) => {
const prop = item.prop;
if (packageJSON[prop] === void 0) {
return;
}
const packages = Object.keys(packageJSON[prop]).filter(
(item) =>
canInstall(item, packageName) &&
ignoreList.indexOf(item) === -1
);
if (!packages.length) {
return;
}
// Update all packages
exec(
packagesDir + '/' + dir,
'npm',
['install', item.cmd].concat(
packages.map((item) => {
const currentVersion = packageJSON[prop][item];
const tag = getTag(item, packageName, currentVersion);
if (typeof tag !== 'string') {
throw new Error(
`Cannot get tag for package "${item}" used in "${packageName}"`
);
}
return item + tag;
})
)
);
});
}
}
/**
* Update dependencies
*/
function update(dir) {
exec(packagesDir + '/' + dir, 'npm', ['update']);
}
/**
* Execute command
*/
function exec(cwd, cmd, args) {
// Execute stuff
console.log(
`Executing in ${cwd.slice(__dirname.length)}: ${cmd} ${args.join(' ')}`
);
const result = child_process.spawnSync(cmd, args, {
cwd,
stdio: 'inherit',
});
if (result.status !== 0) {
process.exit(result.status);
}
// Update symbolic links
child_process.spawnSync('npm', ['run', 'link'], {
__dirname,
stdio: 'inherit',
});
}
/**
* Add directory to list of directories to parse
*/
function addDirToParse(dir) {
if (parseDirs.indexOf(dir) === -1) {
parseDirs.push(dir);
}
}
/**
* Print usage
*/
function usage() {
console.log('Usage: node update-deps [list of packages to update]');
console.log('--all updates all packages');
console.log(
'--install installs @latest versions of dependencies. Use carefully and check code after using it!'
);
console.log('--update updates dependencies (npm update)');
}
/**
* Invalid parameter error. Print usage instructions and throw error
*/
function invalidParam(cmd) {
usage();
throw new Error(`Invalid parameter: ${cmd}`);
}