From eff92a3aa75a6b84aa7f183d840025228d66e008 Mon Sep 17 00:00:00 2001 From: Ansonhkg Date: Wed, 23 Aug 2023 21:09:15 +0100 Subject: [PATCH 01/11] feat: add "group" metadata --- packages/access-control-conditions/package.json | 1 + packages/auth-browser/package.json | 1 + packages/auth-helpers/package.json | 1 + packages/bls-sdk/package.json | 1 + packages/constants/package.json | 1 + packages/contracts-sdk/package.json | 1 + packages/core/package.json | 1 + packages/crypto/package.json | 1 + packages/ecdsa-sdk/package.json | 1 + packages/encryption/package.json | 1 + packages/getlit-sdk/package.json | 3 ++- packages/lit-auth-client/package.json | 1 + packages/lit-node-client-nodejs/package.json | 1 + packages/lit-node-client/package.json | 1 + packages/lit-storage/package.json | 1 + packages/lit-third-party-libs/package.json | 1 + packages/misc-browser/package.json | 1 + packages/misc/package.json | 1 + packages/nacl/package.json | 1 + packages/pkp-base/package.json | 1 + packages/pkp-client/package.json | 1 + packages/pkp-cosmos/package.json | 1 + packages/pkp-ethers/package.json | 1 + packages/pkp-sui/package.json | 1 + packages/pkp-walletconnect/package.json | 1 + packages/types/package.json | 1 + packages/uint8arrays/package.json | 1 + 27 files changed, 28 insertions(+), 1 deletion(-) diff --git a/packages/access-control-conditions/package.json b/packages/access-control-conditions/package.json index 4b46c7b590..53f196d60d 100644 --- a/packages/access-control-conditions/package.json +++ b/packages/access-control-conditions/package.json @@ -22,6 +22,7 @@ "universal" ], "version": "2.2.49", + "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" } \ No newline at end of file diff --git a/packages/auth-browser/package.json b/packages/auth-browser/package.json index b2656291b9..0ef06d2e50 100644 --- a/packages/auth-browser/package.json +++ b/packages/auth-browser/package.json @@ -31,6 +31,7 @@ "browser" ], "version": "2.2.49", + "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" } \ No newline at end of file diff --git a/packages/auth-helpers/package.json b/packages/auth-helpers/package.json index 8a2cbd9cd9..8bc84bad0b 100644 --- a/packages/auth-helpers/package.json +++ b/packages/auth-helpers/package.json @@ -29,6 +29,7 @@ "stream": false }, "version": "2.2.49", + "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" } \ No newline at end of file diff --git a/packages/bls-sdk/package.json b/packages/bls-sdk/package.json index 150a076d66..3f010d5f52 100644 --- a/packages/bls-sdk/package.json +++ b/packages/bls-sdk/package.json @@ -25,6 +25,7 @@ "universal" ], "version": "2.2.49", + "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" } \ No newline at end of file diff --git a/packages/constants/package.json b/packages/constants/package.json index 24989598d9..925ec42b16 100644 --- a/packages/constants/package.json +++ b/packages/constants/package.json @@ -21,6 +21,7 @@ "universal" ], "version": "2.2.49", + "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" } \ No newline at end of file diff --git a/packages/contracts-sdk/package.json b/packages/contracts-sdk/package.json index 8d099a2b62..e41f210367 100644 --- a/packages/contracts-sdk/package.json +++ b/packages/contracts-sdk/package.json @@ -28,6 +28,7 @@ "universal" ], "version": "2.2.49", + "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" } \ No newline at end of file diff --git a/packages/core/package.json b/packages/core/package.json index f4162479da..6b637f662c 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -25,6 +25,7 @@ "tags": [ "universal" ], + "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" } \ No newline at end of file diff --git a/packages/crypto/package.json b/packages/crypto/package.json index d23c43a2d0..de804fc402 100644 --- a/packages/crypto/package.json +++ b/packages/crypto/package.json @@ -22,6 +22,7 @@ "universal" ], "version": "2.2.49", + "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" } \ No newline at end of file diff --git a/packages/ecdsa-sdk/package.json b/packages/ecdsa-sdk/package.json index 16c81cc39f..e6911e3090 100644 --- a/packages/ecdsa-sdk/package.json +++ b/packages/ecdsa-sdk/package.json @@ -22,6 +22,7 @@ "universal" ], "version": "2.2.49", + "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" } \ No newline at end of file diff --git a/packages/encryption/package.json b/packages/encryption/package.json index 7de044a62c..6030056988 100644 --- a/packages/encryption/package.json +++ b/packages/encryption/package.json @@ -26,6 +26,7 @@ "stream": false }, "version": "2.2.49", + "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" } \ No newline at end of file diff --git a/packages/getlit-sdk/package.json b/packages/getlit-sdk/package.json index 5252c96219..a1ef1f1106 100644 --- a/packages/getlit-sdk/package.json +++ b/packages/getlit-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@getlit/sdk", - "version": "2.2.49", + "version": "0.0.4", "type": "commonjs", "license": "MIT", "homepage": "https://github.com/Lit-Protocol/js-sdk", @@ -32,6 +32,7 @@ ".": "./src/index.js", "./autoLoad": "./src/autoLoad.js" }, + "group": "revamp", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" } \ No newline at end of file diff --git a/packages/lit-auth-client/package.json b/packages/lit-auth-client/package.json index 909916c550..3fc0ef6cef 100644 --- a/packages/lit-auth-client/package.json +++ b/packages/lit-auth-client/package.json @@ -30,6 +30,7 @@ "@simplewebauthn/typescript-types": "^7.0.0", "nanoid": "3.3.4" }, + "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" } \ No newline at end of file diff --git a/packages/lit-node-client-nodejs/package.json b/packages/lit-node-client-nodejs/package.json index e008ef8677..6b2355ca54 100644 --- a/packages/lit-node-client-nodejs/package.json +++ b/packages/lit-node-client-nodejs/package.json @@ -25,6 +25,7 @@ "nodejs" ], "version": "2.2.49", + "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" } \ No newline at end of file diff --git a/packages/lit-node-client/package.json b/packages/lit-node-client/package.json index 07f66a8d3b..81aad0ad63 100644 --- a/packages/lit-node-client/package.json +++ b/packages/lit-node-client/package.json @@ -26,6 +26,7 @@ "stream": false }, "version": "2.2.49", + "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" } \ No newline at end of file diff --git a/packages/lit-storage/package.json b/packages/lit-storage/package.json index 77d48d2d43..c51fc6be5d 100644 --- a/packages/lit-storage/package.json +++ b/packages/lit-storage/package.json @@ -25,6 +25,7 @@ "tags": [ "universal" ], + "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" } \ No newline at end of file diff --git a/packages/lit-third-party-libs/package.json b/packages/lit-third-party-libs/package.json index 4808b0ad2f..8d14ad1d74 100644 --- a/packages/lit-third-party-libs/package.json +++ b/packages/lit-third-party-libs/package.json @@ -22,6 +22,7 @@ ], "gitHead": "0d7334c2c55f448e91fe32f29edc5db8f5e09e4b", "version": "2.2.49", + "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" } \ No newline at end of file diff --git a/packages/misc-browser/package.json b/packages/misc-browser/package.json index ae0d7b3291..44deb261d9 100644 --- a/packages/misc-browser/package.json +++ b/packages/misc-browser/package.json @@ -22,6 +22,7 @@ "browser" ], "version": "2.2.49", + "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" } \ No newline at end of file diff --git a/packages/misc/package.json b/packages/misc/package.json index 7e1880bede..fa59843ee6 100644 --- a/packages/misc/package.json +++ b/packages/misc/package.json @@ -25,6 +25,7 @@ "universal" ], "version": "2.2.49", + "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" } \ No newline at end of file diff --git a/packages/nacl/package.json b/packages/nacl/package.json index eac51c8f4a..23504962e3 100644 --- a/packages/nacl/package.json +++ b/packages/nacl/package.json @@ -22,6 +22,7 @@ "directory": "../../dist/packages/nacl" }, "version": "2.2.49", + "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" } \ No newline at end of file diff --git a/packages/pkp-base/package.json b/packages/pkp-base/package.json index 261001aa84..cd7f87d2cc 100644 --- a/packages/pkp-base/package.json +++ b/packages/pkp-base/package.json @@ -25,6 +25,7 @@ "tags": [ "universal" ], + "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" } \ No newline at end of file diff --git a/packages/pkp-client/package.json b/packages/pkp-client/package.json index 619bde0570..5f1562a591 100644 --- a/packages/pkp-client/package.json +++ b/packages/pkp-client/package.json @@ -25,6 +25,7 @@ "tags": [ "universal" ], + "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" } \ No newline at end of file diff --git a/packages/pkp-cosmos/package.json b/packages/pkp-cosmos/package.json index a26c3ae8dc..fd4c45d4ae 100644 --- a/packages/pkp-cosmos/package.json +++ b/packages/pkp-cosmos/package.json @@ -25,6 +25,7 @@ "tags": [ "universal" ], + "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" } \ No newline at end of file diff --git a/packages/pkp-ethers/package.json b/packages/pkp-ethers/package.json index e44d2e4dd7..eefe75f080 100644 --- a/packages/pkp-ethers/package.json +++ b/packages/pkp-ethers/package.json @@ -21,6 +21,7 @@ "universal" ], "version": "2.2.49", + "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" } \ No newline at end of file diff --git a/packages/pkp-sui/package.json b/packages/pkp-sui/package.json index 51085bf791..f4c3c809f9 100644 --- a/packages/pkp-sui/package.json +++ b/packages/pkp-sui/package.json @@ -25,6 +25,7 @@ "tags": [ "universal" ], + "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" } \ No newline at end of file diff --git a/packages/pkp-walletconnect/package.json b/packages/pkp-walletconnect/package.json index 143d2c4452..d1741571c6 100644 --- a/packages/pkp-walletconnect/package.json +++ b/packages/pkp-walletconnect/package.json @@ -31,6 +31,7 @@ "tags": [ "universal" ], + "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" } \ No newline at end of file diff --git a/packages/types/package.json b/packages/types/package.json index 2e98d4bc07..1e3ae58e35 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -21,6 +21,7 @@ "universal" ], "version": "2.2.49", + "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" } \ No newline at end of file diff --git a/packages/uint8arrays/package.json b/packages/uint8arrays/package.json index 337daac214..cd66512a15 100644 --- a/packages/uint8arrays/package.json +++ b/packages/uint8arrays/package.json @@ -22,6 +22,7 @@ "universal" ], "version": "2.2.49", + "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" } \ No newline at end of file From 0b48c2a42a45fb170a3643bc19c4e8545ed4278a Mon Sep 17 00:00:00 2001 From: Ansonhkg Date: Wed, 23 Aug 2023 21:09:59 +0100 Subject: [PATCH 02/11] feat: add support on group --- tools/scripts/tools.mjs | 177 ++++++++++++++++++++++++++-------------- tools/scripts/utils.mjs | 42 +++++++++- 2 files changed, 157 insertions(+), 62 deletions(-) diff --git a/tools/scripts/tools.mjs b/tools/scripts/tools.mjs index e9469c15f8..d8f068a2d0 100644 --- a/tools/scripts/tools.mjs +++ b/tools/scripts/tools.mjs @@ -28,6 +28,9 @@ import { validateGroupIsInConfig, writeGroupConfig, getDefaultGroupVersion, + groupNames, + compareVersions, + greyLog, } from './utils.mjs'; import fs from 'fs'; import path from 'path'; @@ -520,6 +523,7 @@ async function buildFunc() { if (groupFlag) { await childRunCommand(`yarn tools --match-versions --group=${groupFlag}`); } else { + yellowLog('No groupFlag is provided, not a problem. Continuing...'); await childRunCommand(`yarn tools --match-versions`); } @@ -1140,10 +1144,27 @@ async function removeLocalDevFunc() { item.replace('packages/', '') ); - const group = args[1]; + // -- use group flag by default + let group = args[1]; console.log('group', group); - const groupList = await getGroupPackageNames(group, removeList); + let groupList = []; + + // -- use all packages if no group flag is provided + if (!group) { + yellowLog( + `group flag not provided, not a problem, will use all packages...` + ); + + // for each group, get the package names + for (const name of groupNames) { + groupList.push(...(await getGroupPackageNames(name))); + } + } else { + groupList = await getGroupPackageNames(group, removeList); + } + + greenLog('groupList', groupList); if (groupList.length > 0) { removeList = groupList; @@ -1248,44 +1269,58 @@ async function setupLocalDevFunc() { } async function matchVersionsFunc() { - const group = getFlag('--group'); + const allPackages = (await listDirsRecursive('./packages', false)).map( + (item) => item.replace('packages/', '') + ); - let packageList; - let version; + const maxLength = Math.max(...allPackages.map((pkg) => pkg.length)); - if (group) { - validateGroupIsInConfig(group); + await asyncForEach(allPackages, async (pkg) => { + const packageJson = await readJsonFile(`packages/${pkg}/package.json`); - // match group version - greenLog(`Group flag detected: ${group}`); + // -- get the version to be updated to + const group = packageJson.group; - packageList = (await getGroupPackageNames(group)).map((item) => { - return `packages/${item}`; - }); + const groupConfig = getGroupConfig(); - // get group version - version = getGroupConfig().config.find( + const groupName = groupConfig.config.find( + (item) => item.group === group + ).group; + + const groupVersion = groupConfig.config.find( (item) => item.group === group ).version; - } else { - // async foreach packages - packageList = await listDirsRecursive('./packages', false); - // get lerna version - version = getDefaultGroupVersion(); - } + // -- update the version in package.json + let direction = compareVersions(packageJson.version, groupVersion); - await asyncForEach(packageList, async (pkg) => { - const packageJson = await readJsonFile(`${pkg}/package.json`); + if (direction === '<') { + direction = '⬆'; + } else if (direction === '>') { + direction = '⬇'; + } else { + direction = '⬌'; + } - packageJson.version = version; + // Pad the package name to align version numbers + const paddedPkg = pkg.padEnd(maxLength, ' '); - greenLog( - `Updating ${pkg}/package.json version ${packageJson.version} => ${version}...` - ); - await writeJsonFile(`${pkg}/package.json`, packageJson); + if (direction === '⬆') { + greenLog( + `${direction} Updating ${paddedPkg}/package.json version ${packageJson.version} => ${groupVersion}` + ); + } else { + greyLog( + `${direction} Updating ${paddedPkg}/package.json version ${packageJson.version} => ${groupVersion}` + ); + } + + // write + packageJson.version = groupVersion; + await writeJsonFile(`packages/${pkg}/package.json`, packageJson); }); - exit(); + + exit(0); } async function versionFunc() { @@ -1297,7 +1332,11 @@ async function versionFunc() { const groupConfig = getGroupConfig(); - console.log("group:", group) + if (!group) { + redLog(`"group" is undefined when being called in "versionFunc"`); + } + + console.log('group:', group); if (group) { validateGroupIsInConfig(group); @@ -1419,46 +1458,62 @@ async function versionFunc() { } async function validateDependencyVersions() { - const PREFIX = '@lit-protocol'; - const ignoreList = ['']; + const PREFIXES = { + core: '@lit-protocol', + revamp: '@getlit', + }; - const packageList = (await listDirsRecursive('./packages', false)).map( - (item) => { - return `dist/${item}/package.json`; - } - ); + await asyncForEach(groupNames, async (groupName) => { + const PREFIX = PREFIXES[groupName]; + + const allPackages = (await listDirsRecursive('./packages', false)).map( + (item) => { + return `dist/${item}/package.json`; + } + ); - await asyncForEach(packageList, async (pkg, i) => { - const packageJson = await readJsonFile(pkg); - const pkgVersion = packageJson.version; + let packageList = []; - const dependencies = packageJson.dependencies; + await asyncForEach(allPackages, async (pkg, i) => { + const pkgJson = await readJsonFile(pkg); - let total = 0; - let passes = 0; - let fails = 0; + if (pkgJson.name.includes(PREFIX)) { + packageList.push(pkg); + } + }); - // search for dependencies that start with @lit-protocol - for (const [key, value] of Object.entries(dependencies)) { - if (key.includes(PREFIX) && !ignoreList.includes(key)) { - total++; - if (value !== pkgVersion) { - fails++; - } else { - passes++; + console.log(`==================== ${groupName} ====================`); + await asyncForEach(packageList, async (pkg, i) => { + const packageJson = await readJsonFile(pkg); + const pkgVersion = packageJson.version; + const dependencies = packageJson.dependencies; + + let total = 0; + let passes = 0; + let fails = 0; + + // search for dependencies that start with @lit-protocol + for (const [key, value] of Object.entries(dependencies)) { + if (key.includes(PREFIX)) { + total++; + if (value !== pkgVersion) { + fails++; + } else { + passes++; + } } } - } - if (fails > 0) { - redLog( - `❌ ${pkg} has ${fails} dependencies with versions that do not match.` - ); - } else { - greenLog( - `✅ ${i + 1} ${pkg} contains all dependencies with matching versions.` - ); - } + if (fails > 0) { + redLog( + `❌ ${pkg} has ${fails} dependencies with versions that do not match.` + ); + } else { + greenLog( + `✅ ${i + 1} ${pkg} contains all dependencies with matching versions.` + ); + } + }); }); process.exit(); diff --git a/tools/scripts/utils.mjs b/tools/scripts/utils.mjs index da4d1c6466..a1a9eb0d4a 100644 --- a/tools/scripts/utils.mjs +++ b/tools/scripts/utils.mjs @@ -249,6 +249,14 @@ export const yellowLog = (msg, noDash = false) => { } }; +export const greyLog = (msg, noDash = false) => { + if (noDash) { + console.log('\x1b[90m%s\x1b[0m', msg); + } else { + console.log('\x1b[90m%s\x1b[0m', `- ${msg}`); + } +}; + export const question = (str, { yes, no }) => { return new Promise((resolve) => { return rl.question(`- ${str} [yes]/no:`, async (answer) => { @@ -481,6 +489,21 @@ export const versionChecker = (pkg, lernaVersion) => { return { status: 200, message: `${pkg.name}@${version} => @${lernaVersion}` }; }; +export function compareVersions(version1, version2) { + const v1 = version1.split('.').map(Number); + const v2 = version2.split('.').map(Number); + + for (let i = 0; i < 3; i++) { + if (v1[i] > v2[i]) { + return '>'; + } else if (v1[i] < v2[i]) { + return '<'; + } + } + + return '=='; +} + // mini custom test framework // Describe function @@ -734,7 +757,15 @@ export function validateGroupIsInConfig(group) { } export async function getGroupPackageNames(groupName, allPackages) { + if (!groupName) { + redLog(`❌ No group name provided.`); + process.exit(1); + } + + greenLog(`...trying to find "${groupName}"`); + if (!allPackages) { + yellowLog(`🚨 "allPackages" is not provided, getting all packages...`); allPackages = (await listDirsRecursive('./packages', false)).map((item) => item.replace('packages/', '') ); @@ -742,7 +773,7 @@ export async function getGroupPackageNames(groupName, allPackages) { let groupList = []; - greenLog(`🔎 Looking for packages in "${groupName}" group...`, true); + greenLog(`🔎 Looking for packages in "${groupName}" group...`); for (let i = 0; i < allPackages.length; i++) { const pkgName = allPackages[i]; @@ -757,6 +788,13 @@ export async function getGroupPackageNames(groupName, allPackages) { } } + if (groupList.length === 0) { + redLog(`❌ No packages found in "${groupName}" group.`); + process.exit(); + } + + greenLog(`🔎 Found ${groupList.length} packages in "${groupName}" group.`); + return groupList; } @@ -767,3 +805,5 @@ export const getDefaultGroupVersion = () => { return version; }; + +export const groupNames = getGroupConfig().config.map((item) => item.group); From 8b60d494a6e7094699fde46f34a4310a4c047a5c Mon Sep 17 00:00:00 2001 From: Ansonhkg Date: Wed, 23 Aug 2023 21:34:51 +0100 Subject: [PATCH 03/11] feat: update "publish" script --- package.json | 9 +++--- tools/scripts/pub.mjs | 64 ++++++++++++++++++++++++----------------- tools/scripts/tools.mjs | 2 +- 3 files changed, 44 insertions(+), 31 deletions(-) diff --git a/package.json b/package.json index 02fb03ade2..9e841a4e1e 100644 --- a/package.json +++ b/package.json @@ -22,10 +22,11 @@ "test:e2e": "yarn tools --test --e2e run-react-and-test", "test:unit": "yarn test:packages", "test:custom": "yarn tools --test --custom", - "publish:packages": "yarn node ./tools/scripts/pub.mjs --prod", - "publish:dev": "yarn node ./tools/scripts/pub.mjs --tag dev", - "publish:test": "yarn node ./tools/scripts/pub.mjs --tag test", - "publish:revamp": "yarn node ./tools/scripts/pub.mjs --tag revamp", + "publish:packages": "yarn node ./tools/scripts/pub.mjs --prod --group=core", + "publish:dev": "yarn node ./tools/scripts/pub.mjs --tag dev --group=core", + "publish:test": "yarn node ./tools/scripts/pub.mjs --tag test --group=core", + "publish:revamp": "yarn node ./tools/scripts/pub.mjs --prod --group=revamp", + "publish:revamp:dev": "yarn node ./tools/scripts/pub.mjs --tag dev --group=revamp", "publish:app:html": "yarn node ./tools/scripts/build-html.mjs && cd dist/apps/html && vercel --prod", "buildAndPublish": "yarn build:packages && yarn publish:packages", "bbp": "yarn bump && yarn build && yarn publish:dev", diff --git a/tools/scripts/pub.mjs b/tools/scripts/pub.mjs index 557a75e08b..e326c0ea53 100644 --- a/tools/scripts/pub.mjs +++ b/tools/scripts/pub.mjs @@ -22,10 +22,11 @@ const args = getArgs(); const OPTION = args[0]; const VALUE = args[1]; +console.log('⏰ ========== Getting Ready ========== ⏰'); console.log(args); const groupFlag = getFlag('--group'); -console.log('groupFlag:', groupFlag); +greenLog(`⛳️ groupFlag: ${groupFlag}`); if (!OPTION || OPTION === '' || OPTION === '--help') { greenLog( @@ -56,13 +57,14 @@ if (OPTION) { let version; const groupConfig = getGroupConfig(); + if (groupFlag) { version = groupConfig.config.find((item) => item.group === groupFlag).version; } else { version = groupConfig.config.find((item) => item.group === 'core').version; } -console.log('version:', version); +greenLog(`🔥 version: ${version}`); let dirs = await listDirsRecursive('dist/packages', false); let newDirs = []; @@ -77,13 +79,21 @@ if (groupFlag) { } }); }); +} else { + redLog( + `🚨 No group flag is provided! Please provide a group flag eg. "yarn node ./tools/scripts/pub.mjs --tag revamp --group=revamp"` + ); } if (newDirs.length > 0) { dirs = newDirs; } -console.log('Ready to publish the following packages:'); +console.log( + '\n\n========== Ready to publish the following packages ========== \n' +); + +let namespace = await readJsonFile(`${dirs[0]}/package.json`); await asyncForEach(dirs, async (dir) => { const pkg = await readJsonFile(`${dir}/package.json`); @@ -102,8 +112,8 @@ const type = OPTION === '--tag' ? `TAG => ${VALUE} - You will need to install like this: yarn add @lit-protocol/lit-node-client@${VALUE}` - : 'PRODUCTION'; + You will need to install like this: yarn add ${namespace.name}@${VALUE}` + : '🚨 PRODUCTION 🚨'; greenLog( ` @@ -115,27 +125,29 @@ greenLog( // get latest version let publishVersion; -if (!groupFlag) { - try { - let res = await fetch( - 'https://registry.npmjs.org/@lit-protocol/lit-node-client' - ); - - res = await res.json(); - - // get the last one - const modified = Object.keys(res.time).pop(); - - // increase x from 0.0.x to 0.0.x+1 - const version = modified.split('.'); - version[2] = parseInt(version[2]) + 1; - publishVersion = version.join('.'); - console.log('publishVersion', publishVersion); - } catch (e) { - yellowLog( - "Couldn't get latest version from npm, will use the config version" - ); - } +const TAG = getFlag('--tag') ?? 'latest'; + +try { + const groupNpm = getGroupConfig().config.find( + (item) => item.group === groupFlag + ).npm; + greenLog(`...getting latest version from npm: ${groupNpm}`); + let res = await fetch(groupNpm); + + res = await res.json(); + + // get the last one + const foundVersion = res['dist-tags'][TAG ?? 'latest']; + + // increase x from 0.0.x to 0.0.x+1 + const version = foundVersion.split('.'); + version[2] = parseInt(version[2]) + 1; + publishVersion = version.join('.'); + greenLog(`ℹ️ Version "${publishVersion}" found on NPM\n`); +} catch (e) { + yellowLog( + "Couldn't get latest version from npm, will use the config version" + ); } await question('Are you sure you want to publish to? (y/n)', { diff --git a/tools/scripts/tools.mjs b/tools/scripts/tools.mjs index d8f068a2d0..3992c96a3d 100644 --- a/tools/scripts/tools.mjs +++ b/tools/scripts/tools.mjs @@ -531,7 +531,7 @@ async function buildFunc() { .map((item) => item.replace('apps/', '')) .join(','); - console.log('groupFlag:', groupFlag); + console.log("🚀 Versions checked! Let's build some packages!"); let groupPackageNames; let additionalIgnoreList; From cdf38086b87912e02c16030491c80f0ff2c90ac2 Mon Sep 17 00:00:00 2001 From: Ansonhkg Date: Wed, 23 Aug 2023 21:35:05 +0100 Subject: [PATCH 04/11] chore: update all package versions --- lit.group.json | 4 ++-- packages/access-control-conditions/package.json | 2 +- packages/auth-browser/package.json | 2 +- packages/auth-helpers/package.json | 2 +- packages/bls-sdk/package.json | 2 +- packages/constants/package.json | 2 +- packages/contracts-sdk/package.json | 2 +- packages/core/package.json | 2 +- packages/crypto/package.json | 2 +- packages/ecdsa-sdk/package.json | 2 +- packages/encryption/package.json | 2 +- packages/getlit-sdk/package.json | 2 +- packages/lit-auth-client/package.json | 2 +- packages/lit-node-client-nodejs/package.json | 2 +- packages/lit-node-client/package.json | 2 +- packages/lit-storage/package.json | 2 +- packages/lit-third-party-libs/package.json | 2 +- packages/misc-browser/package.json | 2 +- packages/misc/package.json | 2 +- packages/nacl/package.json | 2 +- packages/pkp-base/package.json | 2 +- packages/pkp-client/package.json | 2 +- packages/pkp-cosmos/package.json | 2 +- packages/pkp-ethers/package.json | 2 +- packages/pkp-sui/package.json | 2 +- packages/pkp-walletconnect/package.json | 2 +- packages/types/package.json | 2 +- packages/uint8arrays/package.json | 2 +- 28 files changed, 29 insertions(+), 29 deletions(-) diff --git a/lit.group.json b/lit.group.json index e9a9521576..158c0f8c1a 100644 --- a/lit.group.json +++ b/lit.group.json @@ -1,12 +1,12 @@ [ { "group": "core", - "version": "2.2.49", + "version": "2.2.51", "npm": "https://registry.npmjs.org/@lit-protocol/lit-node-client" }, { "group": "revamp", - "version": "0.0.4", + "version": "0.0.7", "npm": "https://registry.npmjs.org/@getlit/sdk" } ] \ No newline at end of file diff --git a/packages/access-control-conditions/package.json b/packages/access-control-conditions/package.json index 53f196d60d..c1c37b2d55 100644 --- a/packages/access-control-conditions/package.json +++ b/packages/access-control-conditions/package.json @@ -21,7 +21,7 @@ "tags": [ "universal" ], - "version": "2.2.49", + "version": "2.2.51", "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" diff --git a/packages/auth-browser/package.json b/packages/auth-browser/package.json index 0ef06d2e50..68659c40b0 100644 --- a/packages/auth-browser/package.json +++ b/packages/auth-browser/package.json @@ -30,7 +30,7 @@ "tags": [ "browser" ], - "version": "2.2.49", + "version": "2.2.51", "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" diff --git a/packages/auth-helpers/package.json b/packages/auth-helpers/package.json index 8bc84bad0b..e6bedb519e 100644 --- a/packages/auth-helpers/package.json +++ b/packages/auth-helpers/package.json @@ -28,7 +28,7 @@ "crypto": false, "stream": false }, - "version": "2.2.49", + "version": "2.2.51", "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" diff --git a/packages/bls-sdk/package.json b/packages/bls-sdk/package.json index 3f010d5f52..048220403b 100644 --- a/packages/bls-sdk/package.json +++ b/packages/bls-sdk/package.json @@ -24,7 +24,7 @@ "tags": [ "universal" ], - "version": "2.2.49", + "version": "2.2.51", "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" diff --git a/packages/constants/package.json b/packages/constants/package.json index 925ec42b16..f46ee59fbb 100644 --- a/packages/constants/package.json +++ b/packages/constants/package.json @@ -20,7 +20,7 @@ "tags": [ "universal" ], - "version": "2.2.49", + "version": "2.2.51", "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" diff --git a/packages/contracts-sdk/package.json b/packages/contracts-sdk/package.json index e41f210367..60c06b3f2b 100644 --- a/packages/contracts-sdk/package.json +++ b/packages/contracts-sdk/package.json @@ -27,7 +27,7 @@ "tags": [ "universal" ], - "version": "2.2.49", + "version": "2.2.51", "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" diff --git a/packages/core/package.json b/packages/core/package.json index 6b637f662c..4f7a3c6194 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@lit-protocol/core", - "version": "2.2.49", + "version": "2.2.51", "type": "commonjs", "license": "MIT", "homepage": "https://github.com/Lit-Protocol/js-sdk", diff --git a/packages/crypto/package.json b/packages/crypto/package.json index de804fc402..50e1007ce0 100644 --- a/packages/crypto/package.json +++ b/packages/crypto/package.json @@ -21,7 +21,7 @@ "tags": [ "universal" ], - "version": "2.2.49", + "version": "2.2.51", "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" diff --git a/packages/ecdsa-sdk/package.json b/packages/ecdsa-sdk/package.json index e6911e3090..c7a05801f2 100644 --- a/packages/ecdsa-sdk/package.json +++ b/packages/ecdsa-sdk/package.json @@ -21,7 +21,7 @@ "tags": [ "universal" ], - "version": "2.2.49", + "version": "2.2.51", "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" diff --git a/packages/encryption/package.json b/packages/encryption/package.json index 6030056988..980e39de1b 100644 --- a/packages/encryption/package.json +++ b/packages/encryption/package.json @@ -25,7 +25,7 @@ "crypto": false, "stream": false }, - "version": "2.2.49", + "version": "2.2.51", "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" diff --git a/packages/getlit-sdk/package.json b/packages/getlit-sdk/package.json index a1ef1f1106..1d88c80237 100644 --- a/packages/getlit-sdk/package.json +++ b/packages/getlit-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@getlit/sdk", - "version": "0.0.4", + "version": "0.0.7", "type": "commonjs", "license": "MIT", "homepage": "https://github.com/Lit-Protocol/js-sdk", diff --git a/packages/lit-auth-client/package.json b/packages/lit-auth-client/package.json index 3fc0ef6cef..d9910d78b0 100644 --- a/packages/lit-auth-client/package.json +++ b/packages/lit-auth-client/package.json @@ -1,6 +1,6 @@ { "name": "@lit-protocol/lit-auth-client", - "version": "2.2.49", + "version": "2.2.51", "type": "commonjs", "license": "MIT", "homepage": "https://github.com/Lit-Protocol/js-sdk", diff --git a/packages/lit-node-client-nodejs/package.json b/packages/lit-node-client-nodejs/package.json index 6b2355ca54..d20d2ea4ad 100644 --- a/packages/lit-node-client-nodejs/package.json +++ b/packages/lit-node-client-nodejs/package.json @@ -24,7 +24,7 @@ "tags": [ "nodejs" ], - "version": "2.2.49", + "version": "2.2.51", "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" diff --git a/packages/lit-node-client/package.json b/packages/lit-node-client/package.json index 81aad0ad63..3db3dd733b 100644 --- a/packages/lit-node-client/package.json +++ b/packages/lit-node-client/package.json @@ -25,7 +25,7 @@ "crypto": false, "stream": false }, - "version": "2.2.49", + "version": "2.2.51", "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" diff --git a/packages/lit-storage/package.json b/packages/lit-storage/package.json index c51fc6be5d..a493a3473e 100644 --- a/packages/lit-storage/package.json +++ b/packages/lit-storage/package.json @@ -1,6 +1,6 @@ { "name": "@lit-protocol/lit-storage", - "version": "2.2.49", + "version": "2.2.51", "type": "commonjs", "license": "MIT", "homepage": "https://github.com/Lit-Protocol/js-sdk", diff --git a/packages/lit-third-party-libs/package.json b/packages/lit-third-party-libs/package.json index 8d14ad1d74..d9e6c3636e 100644 --- a/packages/lit-third-party-libs/package.json +++ b/packages/lit-third-party-libs/package.json @@ -21,7 +21,7 @@ "universal" ], "gitHead": "0d7334c2c55f448e91fe32f29edc5db8f5e09e4b", - "version": "2.2.49", + "version": "2.2.51", "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" diff --git a/packages/misc-browser/package.json b/packages/misc-browser/package.json index 44deb261d9..1abdedb21c 100644 --- a/packages/misc-browser/package.json +++ b/packages/misc-browser/package.json @@ -21,7 +21,7 @@ "tags": [ "browser" ], - "version": "2.2.49", + "version": "2.2.51", "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" diff --git a/packages/misc/package.json b/packages/misc/package.json index fa59843ee6..5559a1d98e 100644 --- a/packages/misc/package.json +++ b/packages/misc/package.json @@ -24,7 +24,7 @@ "tags": [ "universal" ], - "version": "2.2.49", + "version": "2.2.51", "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" diff --git a/packages/nacl/package.json b/packages/nacl/package.json index 23504962e3..8a11fd48d5 100644 --- a/packages/nacl/package.json +++ b/packages/nacl/package.json @@ -21,7 +21,7 @@ "access": "public", "directory": "../../dist/packages/nacl" }, - "version": "2.2.49", + "version": "2.2.51", "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" diff --git a/packages/pkp-base/package.json b/packages/pkp-base/package.json index cd7f87d2cc..f10cc14002 100644 --- a/packages/pkp-base/package.json +++ b/packages/pkp-base/package.json @@ -1,6 +1,6 @@ { "name": "@lit-protocol/pkp-base", - "version": "2.2.49", + "version": "2.2.51", "type": "commonjs", "license": "MIT", "homepage": "https://github.com/Lit-Protocol/js-sdk", diff --git a/packages/pkp-client/package.json b/packages/pkp-client/package.json index 5f1562a591..c294701268 100644 --- a/packages/pkp-client/package.json +++ b/packages/pkp-client/package.json @@ -1,6 +1,6 @@ { "name": "@lit-protocol/pkp-client", - "version": "2.2.49", + "version": "2.2.51", "type": "commonjs", "license": "MIT", "homepage": "https://github.com/Lit-Protocol/js-sdk", diff --git a/packages/pkp-cosmos/package.json b/packages/pkp-cosmos/package.json index fd4c45d4ae..ec49d04174 100644 --- a/packages/pkp-cosmos/package.json +++ b/packages/pkp-cosmos/package.json @@ -1,6 +1,6 @@ { "name": "@lit-protocol/pkp-cosmos", - "version": "2.2.49", + "version": "2.2.51", "type": "commonjs", "license": "MIT", "homepage": "https://github.com/Lit-Protocol/js-sdk", diff --git a/packages/pkp-ethers/package.json b/packages/pkp-ethers/package.json index eefe75f080..38150254df 100644 --- a/packages/pkp-ethers/package.json +++ b/packages/pkp-ethers/package.json @@ -20,7 +20,7 @@ "tags": [ "universal" ], - "version": "2.2.49", + "version": "2.2.51", "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" diff --git a/packages/pkp-sui/package.json b/packages/pkp-sui/package.json index f4c3c809f9..e162f0b9e4 100644 --- a/packages/pkp-sui/package.json +++ b/packages/pkp-sui/package.json @@ -1,6 +1,6 @@ { "name": "@lit-protocol/pkp-sui", - "version": "2.2.49", + "version": "2.2.51", "type": "commonjs", "license": "MIT", "homepage": "https://github.com/Lit-Protocol/js-sdk", diff --git a/packages/pkp-walletconnect/package.json b/packages/pkp-walletconnect/package.json index d1741571c6..96c85b0402 100644 --- a/packages/pkp-walletconnect/package.json +++ b/packages/pkp-walletconnect/package.json @@ -1,6 +1,6 @@ { "name": "@lit-protocol/pkp-walletconnect", - "version": "2.2.49", + "version": "2.2.51", "type": "commonjs", "license": "MIT", "homepage": "https://github.com/Lit-Protocol/js-sdk", diff --git a/packages/types/package.json b/packages/types/package.json index 1e3ae58e35..23e13cfe45 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -20,7 +20,7 @@ "tags": [ "universal" ], - "version": "2.2.49", + "version": "2.2.51", "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" diff --git a/packages/uint8arrays/package.json b/packages/uint8arrays/package.json index cd66512a15..21e3873802 100644 --- a/packages/uint8arrays/package.json +++ b/packages/uint8arrays/package.json @@ -21,7 +21,7 @@ "tags": [ "universal" ], - "version": "2.2.49", + "version": "2.2.51", "group": "core", "main": "./dist/src/index.js", "typings": "./dist/src/index.d.ts" From 09e178d3430632050561143b38a1b4bf28278ed7 Mon Sep 17 00:00:00 2001 From: Ansonhkg Date: Wed, 23 Aug 2023 22:20:12 +0100 Subject: [PATCH 05/11] feat: add "whatPackages" --- tools/scripts/what-packages.mjs | 64 +++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 tools/scripts/what-packages.mjs diff --git a/tools/scripts/what-packages.mjs b/tools/scripts/what-packages.mjs new file mode 100644 index 0000000000..be4f6a3b2c --- /dev/null +++ b/tools/scripts/what-packages.mjs @@ -0,0 +1,64 @@ +/** + * EMS Function to Recursively Search for Imports by a Given String + * + * Usage Example: + * ```javascript + * import { findImports } from './path-to-this-file.mjs'; + * + * const searchString = '@lit-protocol'; + * const pathToSearch = './src'; + * + * const results = findImports(searchString, pathToSearch); + * console.log(results); // ['@lit-protocol/lit-storage', '@lit-protocol/lit-auth-client'] + * ``` + */ + +// what-packages.mjs + +import { promises as fs } from 'fs'; +import path from 'path'; + +async function findImports(targetString, searchPath) { + const allFiles = await listFilesRecursive(searchPath); + const targetFiles = allFiles.filter((file) => file.endsWith('.ts')); + + const matches = new Set(); + + for (const file of targetFiles) { + const content = await fs.readFile(file, 'utf-8'); + const regex = new RegExp(`from ['"](${targetString}[^'"]+)['"]`, 'g'); + let match; + while ((match = regex.exec(content)) !== null) { + matches.add(match[1]); + } + } + + return [...matches]; +} + +async function listFilesRecursive(dir) { + const dirents = await fs.readdir(dir, { withFileTypes: true }); + const files = await Promise.all( + dirents.map((dirent) => { + const res = path.resolve(dir, dirent.name); + return dirent.isDirectory() ? listFilesRecursive(res) : res; + }) + ); + return Array.prototype.concat(...files); +} + +const args = process.argv.slice(2); +const searchString = args[0] || '@lit-protocol'; +const searchPath = args[1] || './src'; + +const results = await findImports(searchString, searchPath); + +console.log('Results:', results); + +console.log(`"peerDependencies": {`); +results.forEach((dep, index) => { + console.log( + ` "${dep}": "*"${index === results.length - 1 ? '' : ','}` + ); +}); +console.log(`}`); From deaaa37868308a61701d7050f9c8b2cedff5b2ab Mon Sep 17 00:00:00 2001 From: Ansonhkg Date: Wed, 23 Aug 2023 22:20:29 +0100 Subject: [PATCH 06/11] chore: update scripts --- lit.group.json | 6 ++++-- package.json | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lit.group.json b/lit.group.json index 158c0f8c1a..cf248cc040 100644 --- a/lit.group.json +++ b/lit.group.json @@ -1,12 +1,14 @@ [ { + "namespace": "@lit-protocol", "group": "core", - "version": "2.2.51", + "version": "2.2.50", "npm": "https://registry.npmjs.org/@lit-protocol/lit-node-client" }, { + "namespace":"@getlit", "group": "revamp", - "version": "0.0.7", + "version": "0.0.9", "npm": "https://registry.npmjs.org/@getlit/sdk" } ] \ No newline at end of file diff --git a/package.json b/package.json index 9e841a4e1e..af8b9db958 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,8 @@ "txServer": "node tx-handler-server.mjs", "prettier": "nx format:write --all", "delete:merged-branches": "git branch --merged | egrep -v '(^\\*|master|main|develop)' | xargs git branch -d", - "delete:no-merged-branches": "git branch --no-merged | egrep -v '(^\\*|master|main|develop)' | xargs git branch -d" + "delete:no-merged-branches": "git branch --no-merged | egrep -v '(^\\*|master|main|develop)' | xargs git branch -d", + "what:packages": "node ./tools/scripts/what-packages.mjs @lit-protocol ./packages/getlit-sdk" }, "private": true, "dependencies": { From 56e358440c55de674ecfbe044d00d26084b2d1d0 Mon Sep 17 00:00:00 2001 From: Ansonhkg Date: Wed, 23 Aug 2023 23:48:54 +0100 Subject: [PATCH 07/11] feat: "yarn bump" for @getlit/sdk --- package.json | 9 ++++++--- tools/scripts/tools.mjs | 10 +--------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index af8b9db958..4627d9d835 100644 --- a/package.json +++ b/package.json @@ -50,9 +50,12 @@ "apps": "yarn tools --dev --apps", "watch": "yarn tools --watch", "v": "yarn tools v", - "bump": "yarn tools v --patch", - "bump:minor": "yarn tools v --minor", - "bump:major": "yarn tools v --major", + "bump": "yarn tools --version --patch --group=core", + "bump:minor": "yarn tools --version --minor --group=core", + "bump:major": "yarn tools --version --major --group=core", + "bump:revamp": "yarn tools --version --patch --group=revamp", + "bump:revamp:minor": "yarn tools --version --minor --group=revamp", + "bump:revamp:major": "yarn tools --version --major --group=revamp", "b": "git branch --show", "txServer": "node tx-handler-server.mjs", "prettier": "nx format:write --all", diff --git a/tools/scripts/tools.mjs b/tools/scripts/tools.mjs index 3992c96a3d..f68a671de8 100644 --- a/tools/scripts/tools.mjs +++ b/tools/scripts/tools.mjs @@ -56,7 +56,6 @@ const optionMaps = new Map([ ['--setup-local-dev', () => setupLocalDevFunc()], ['--match-versions', () => matchVersionsFunc()], ['default', () => helpFunc()], - ['v', () => versionFunc()], ['--version', () => versionFunc()], ['--verify', () => validateDependencyVersions()], ['--postBuild', () => buildTestApps()], @@ -1334,16 +1333,9 @@ async function versionFunc() { if (!group) { redLog(`"group" is undefined when being called in "versionFunc"`); + process.exit(1); } - console.log('group:', group); - - if (group) { - validateGroupIsInConfig(group); - } else { - group = 'core'; - // url = 'https://registry.npmjs.org/@lit-protocol/lit-node-client'; - } url = groupConfig.config.find((item) => item.group === group).npm; res = await fetch(url); From 53a7679ccc6c047e17768569c54f3e5de4b7c84c Mon Sep 17 00:00:00 2001 From: Ansonhkg Date: Thu, 24 Aug 2023 00:03:24 +0100 Subject: [PATCH 08/11] chore: update log --- tools/scripts/what-packages.mjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/scripts/what-packages.mjs b/tools/scripts/what-packages.mjs index be4f6a3b2c..fb47f910e3 100644 --- a/tools/scripts/what-packages.mjs +++ b/tools/scripts/what-packages.mjs @@ -53,8 +53,9 @@ const searchPath = args[1] || './src'; const results = await findImports(searchString, searchPath); -console.log('Results:', results); +console.log('\n========== Results ==========\n', results); +console.log("\n========== Copy/Paste into package.json's peerDependencies ==========\n"); console.log(`"peerDependencies": {`); results.forEach((dep, index) => { console.log( From 72d1bd9c982791ad9f2aa0a18ce131eca7af812b Mon Sep 17 00:00:00 2001 From: Ansonhkg Date: Thu, 24 Aug 2023 00:07:49 +0100 Subject: [PATCH 09/11] chore: update script --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4627d9d835..524f684937 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "prettier": "nx format:write --all", "delete:merged-branches": "git branch --merged | egrep -v '(^\\*|master|main|develop)' | xargs git branch -d", "delete:no-merged-branches": "git branch --no-merged | egrep -v '(^\\*|master|main|develop)' | xargs git branch -d", - "what:packages": "node ./tools/scripts/what-packages.mjs @lit-protocol ./packages/getlit-sdk" + "what:packages": "node ./tools/scripts/what-packages.mjs" }, "private": true, "dependencies": { From aab7103cf894fed76e33ca9aa723fc3a4f956664 Mon Sep 17 00:00:00 2001 From: Ansonhkg Date: Thu, 24 Aug 2023 00:22:03 +0100 Subject: [PATCH 10/11] chore: update ui --- tools/scripts/tools.mjs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tools/scripts/tools.mjs b/tools/scripts/tools.mjs index f68a671de8..3fb4a93bdf 100644 --- a/tools/scripts/tools.mjs +++ b/tools/scripts/tools.mjs @@ -1473,8 +1473,15 @@ async function validateDependencyVersions() { packageList.push(pkg); } }); + const maxLength = Math.max(...packageList.map((pkg) => pkg.length)); + + const maxIndexLength = packageList.length < 10 ? 1 : 2; + const maxLineLength = maxIndexLength + 2 + maxLength + 45; + const separatorLength = maxLineLength - groupName.length - 2; // subtract 2 for the spaces on either side of the groupName + const separator = '='.repeat(separatorLength / 2); + + console.log(`\n${separator} ${groupName} packages ${separator}`); - console.log(`==================== ${groupName} ====================`); await asyncForEach(packageList, async (pkg, i) => { const packageJson = await readJsonFile(pkg); const pkgVersion = packageJson.version; @@ -1496,13 +1503,16 @@ async function validateDependencyVersions() { } } + const paddedPkg = pkg.padEnd(maxLength, ' '); + const paddedIndex = (i + 1).toString().padStart(maxIndexLength, ' '); + if (fails > 0) { redLog( - `❌ ${pkg} has ${fails} dependencies with versions that do not match.` + `❌ ${paddedIndex} ${paddedPkg} has ${fails} dependencies with versions that do not match.` ); } else { greenLog( - `✅ ${i + 1} ${pkg} contains all dependencies with matching versions.` + `✅ ${paddedIndex} ${paddedPkg} contains all dependencies with matching versions.` ); } }); From 7de5bc286aa43771cecdd560f47cc9ae58f597fc Mon Sep 17 00:00:00 2001 From: Ansonhkg Date: Thu, 24 Aug 2023 00:43:33 +0100 Subject: [PATCH 11/11] chore: improve DX --- lit.group.json | 6 ++--- packages/getlit-sdk/package.json | 2 +- packages/getlit-sdk/src/lib/utils.ts | 2 +- tools/scripts/pub.mjs | 36 +++++++++++++++++++++------- tools/scripts/utils.mjs | 9 ++++--- 5 files changed, 39 insertions(+), 16 deletions(-) diff --git a/lit.group.json b/lit.group.json index cf248cc040..2e72c823cb 100644 --- a/lit.group.json +++ b/lit.group.json @@ -2,13 +2,13 @@ { "namespace": "@lit-protocol", "group": "core", - "version": "2.2.50", + "version": "2.2.51", "npm": "https://registry.npmjs.org/@lit-protocol/lit-node-client" }, { - "namespace":"@getlit", + "namespace": "@getlit", "group": "revamp", - "version": "0.0.9", + "version": "0.0.10", "npm": "https://registry.npmjs.org/@getlit/sdk" } ] \ No newline at end of file diff --git a/packages/getlit-sdk/package.json b/packages/getlit-sdk/package.json index 1d88c80237..ecc518284a 100644 --- a/packages/getlit-sdk/package.json +++ b/packages/getlit-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@getlit/sdk", - "version": "0.0.7", + "version": "0.0.10", "type": "commonjs", "license": "MIT", "homepage": "https://github.com/Lit-Protocol/js-sdk", diff --git a/packages/getlit-sdk/src/lib/utils.ts b/packages/getlit-sdk/src/lib/utils.ts index 8e35e99504..9ae29b533f 100644 --- a/packages/getlit-sdk/src/lib/utils.ts +++ b/packages/getlit-sdk/src/lib/utils.ts @@ -24,7 +24,7 @@ import { BaseAuthenticateOptions, } from '@lit-protocol/types'; -const version = '0.0.714'; +const version = '0.0.715'; const PREFIX = 'GetLit SDK'; const logBuffer: Array = []; diff --git a/tools/scripts/pub.mjs b/tools/scripts/pub.mjs index e326c0ea53..216af80854 100644 --- a/tools/scripts/pub.mjs +++ b/tools/scripts/pub.mjs @@ -83,8 +83,18 @@ if (groupFlag) { redLog( `🚨 No group flag is provided! Please provide a group flag eg. "yarn node ./tools/scripts/pub.mjs --tag revamp --group=revamp"` ); + process.exit(1); } +const groupNPM = groupConfig.config.find( + (item) => item.group === groupFlag +).npm; + +const npmVersionRes = await fetch(groupNPM); +let npmVersion = await npmVersionRes.json(); + +npmVersion = Object.keys(npmVersion.time).pop(); + if (newDirs.length > 0) { dirs = newDirs; } @@ -95,16 +105,20 @@ console.log( let namespace = await readJsonFile(`${dirs[0]}/package.json`); +const maxNameLength = Math.max(...dirs.map((dir) => dir.length)); + await asyncForEach(dirs, async (dir) => { - const pkg = await readJsonFile(`${dir}/package.json`); + const distPkg = await readJsonFile(`${dir}/package.json`); + + const paddedName = distPkg.name.padEnd(maxNameLength, ' '); - greenLog(`${pkg.name} => ${pkg.version}`); + greenLog(`${paddedName} ${npmVersion} => ${distPkg.version}`); // remove peer dependencies - delete pkg.peerDependencies; + delete distPkg.peerDependencies; // write the package.json file - await writeJsonFile(`${dir}/package.json`, pkg); + await writeJsonFile(`${dir}/package.json`, distPkg); }); // prompt user to confirm publish @@ -117,7 +131,7 @@ const type = greenLog( ` - Publishing: ${type} + 🚨 Publishing: ${type} `, true ); @@ -125,13 +139,19 @@ greenLog( // get latest version let publishVersion; -const TAG = getFlag('--tag') ?? 'latest'; +let TAG; + +try { + TAG = getFlag('--tag', false); +} catch (e) { + TAG = 'latest'; +} try { const groupNpm = getGroupConfig().config.find( (item) => item.group === groupFlag ).npm; - greenLog(`...getting latest version from npm: ${groupNpm}`); + // greenLog(`...getting latest version from npm: ${groupNpm}`); let res = await fetch(groupNpm); res = await res.json(); @@ -143,7 +163,7 @@ try { const version = foundVersion.split('.'); version[2] = parseInt(version[2]) + 1; publishVersion = version.join('.'); - greenLog(`ℹ️ Version "${publishVersion}" found on NPM\n`); + // greenLog(`ℹ️ Version "${publishVersion}" found on NPM\n`); } catch (e) { yellowLog( "Couldn't get latest version from npm, will use the config version" diff --git a/tools/scripts/utils.mjs b/tools/scripts/utils.mjs index a1a9eb0d4a..8d56c06d4a 100644 --- a/tools/scripts/utils.mjs +++ b/tools/scripts/utils.mjs @@ -630,7 +630,7 @@ export function findArg(args, flag) { } } -export const getFlag = (flag = '--foo') => { +export const getFlag = (flag = '--foo', exit = true) => { try { const args = process.argv.slice(2); @@ -639,8 +639,11 @@ export const getFlag = (flag = '--foo') => { const value = args[index].split('=')[1]; if (!value) { - redLog(`❌ "${flag}" value cannot be empty. eg. ${flag}=bar`); - process.exit(); + yellowLog(`👀 "${flag}" value is empty. eg. ${flag}=bar`); + + if(exit){ + process.exit(); + } } return value;