From 63cab0414ca0a2dd137f5941c5311856c17af090 Mon Sep 17 00:00:00 2001 From: Cameron Griffin Date: Thu, 23 Feb 2023 11:40:48 -0500 Subject: [PATCH 1/8] initial commit --- yarn2npm/package-lock.json | 753 +++++++++++++++++++++++++++++++++++++ yarn2npm/package.json | 14 + yarn2npm/yarn2npm.js | 97 +++++ 3 files changed, 864 insertions(+) create mode 100644 yarn2npm/package-lock.json create mode 100644 yarn2npm/package.json create mode 100644 yarn2npm/yarn2npm.js diff --git a/yarn2npm/package-lock.json b/yarn2npm/package-lock.json new file mode 100644 index 0000000..983fe0d --- /dev/null +++ b/yarn2npm/package-lock.json @@ -0,0 +1,753 @@ +{ + "name": "yarn2npm", + "version": "1.0.0", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "yarn2npm", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "@actions/github": "^5.1.1", + "isomorphic-git": "^1.21.0" + } + }, + "node_modules/@actions/github": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@actions/github/-/github-5.1.1.tgz", + "integrity": "sha512-Nk59rMDoJaV+mHCOJPXuvB1zIbomlKS0dmSIqPGxd0enAXBnOfn4VWF+CGtRCwXZG9Epa54tZA7VIRlJDS8A6g==", + "dependencies": { + "@actions/http-client": "^2.0.1", + "@octokit/core": "^3.6.0", + "@octokit/plugin-paginate-rest": "^2.17.0", + "@octokit/plugin-rest-endpoint-methods": "^5.13.0" + } + }, + "node_modules/@actions/http-client": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.1.tgz", + "integrity": "sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==", + "dependencies": { + "tunnel": "^0.0.6" + } + }, + "node_modules/@octokit/auth-token": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-2.5.0.tgz", + "integrity": "sha512-r5FVUJCOLl19AxiuZD2VRZ/ORjp/4IN98Of6YJoJOkY75CIBuYfmiNHGrDwXr+aLGG55igl9QrxX3hbiXlLb+g==", + "dependencies": { + "@octokit/types": "^6.0.3" + } + }, + "node_modules/@octokit/core": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/@octokit/core/-/core-3.6.0.tgz", + "integrity": "sha512-7RKRKuA4xTjMhY+eG3jthb3hlZCsOwg3rztWh75Xc+ShDWOfDDATWbeZpAHBNRpm4Tv9WgBMOy1zEJYXG6NJ7Q==", + "dependencies": { + "@octokit/auth-token": "^2.4.4", + "@octokit/graphql": "^4.5.8", + "@octokit/request": "^5.6.3", + "@octokit/request-error": "^2.0.5", + "@octokit/types": "^6.0.3", + "before-after-hook": "^2.2.0", + "universal-user-agent": "^6.0.0" + } + }, + "node_modules/@octokit/endpoint": { + "version": "6.0.12", + "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-6.0.12.tgz", + "integrity": "sha512-lF3puPwkQWGfkMClXb4k/eUT/nZKQfxinRWJrdZaJO85Dqwo/G0yOC434Jr2ojwafWJMYqFGFa5ms4jJUgujdA==", + "dependencies": { + "@octokit/types": "^6.0.3", + "is-plain-object": "^5.0.0", + "universal-user-agent": "^6.0.0" + } + }, + "node_modules/@octokit/graphql": { + "version": "4.8.0", + "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-4.8.0.tgz", + "integrity": "sha512-0gv+qLSBLKF0z8TKaSKTsS39scVKF9dbMxJpj3U0vC7wjNWFuIpL/z76Qe2fiuCbDRcJSavkXsVtMS6/dtQQsg==", + "dependencies": { + "@octokit/request": "^5.6.0", + "@octokit/types": "^6.0.3", + "universal-user-agent": "^6.0.0" + } + }, + "node_modules/@octokit/openapi-types": { + "version": "12.11.0", + "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-12.11.0.tgz", + "integrity": "sha512-VsXyi8peyRq9PqIz/tpqiL2w3w80OgVMwBHltTml3LmVvXiphgeqmY9mvBw9Wu7e0QWk/fqD37ux8yP5uVekyQ==" + }, + "node_modules/@octokit/plugin-paginate-rest": { + "version": "2.21.3", + "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.21.3.tgz", + "integrity": "sha512-aCZTEf0y2h3OLbrgKkrfFdjRL6eSOo8komneVQJnYecAxIej7Bafor2xhuDJOIFau4pk0i/P28/XgtbyPF0ZHw==", + "dependencies": { + "@octokit/types": "^6.40.0" + }, + "peerDependencies": { + "@octokit/core": ">=2" + } + }, + "node_modules/@octokit/plugin-rest-endpoint-methods": { + "version": "5.16.2", + "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-5.16.2.tgz", + "integrity": "sha512-8QFz29Fg5jDuTPXVtey05BLm7OB+M8fnvE64RNegzX7U+5NUXcOcnpTIK0YfSHBg8gYd0oxIq3IZTe9SfPZiRw==", + "dependencies": { + "@octokit/types": "^6.39.0", + "deprecation": "^2.3.1" + }, + "peerDependencies": { + "@octokit/core": ">=3" + } + }, + "node_modules/@octokit/request": { + "version": "5.6.3", + "resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.6.3.tgz", + "integrity": "sha512-bFJl0I1KVc9jYTe9tdGGpAMPy32dLBXXo1dS/YwSCTL/2nd9XeHsY616RE3HPXDVk+a+dBuzyz5YdlXwcDTr2A==", + "dependencies": { + "@octokit/endpoint": "^6.0.1", + "@octokit/request-error": "^2.1.0", + "@octokit/types": "^6.16.1", + "is-plain-object": "^5.0.0", + "node-fetch": "^2.6.7", + "universal-user-agent": "^6.0.0" + } + }, + "node_modules/@octokit/request-error": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-2.1.0.tgz", + "integrity": "sha512-1VIvgXxs9WHSjicsRwq8PlR2LR2x6DwsJAaFgzdi0JfJoGSO8mYI/cHJQ+9FbN21aa+DrgNLnwObmyeSC8Rmpg==", + "dependencies": { + "@octokit/types": "^6.0.3", + "deprecation": "^2.0.0", + "once": "^1.4.0" + } + }, + "node_modules/@octokit/types": { + "version": "6.41.0", + "resolved": "https://registry.npmjs.org/@octokit/types/-/types-6.41.0.tgz", + "integrity": "sha512-eJ2jbzjdijiL3B4PrSQaSjuF2sPEQPVCPzBvTHJD9Nz+9dw2SGH4K4xeQJ77YfTq5bRQ+bD8wT11JbeDPmxmGg==", + "dependencies": { + "@octokit/openapi-types": "^12.11.0" + } + }, + "node_modules/async-lock": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/async-lock/-/async-lock-1.4.0.tgz", + "integrity": "sha512-coglx5yIWuetakm3/1dsX9hxCNox22h7+V80RQOu2XUUMidtArxKoZoOtHUPuR84SycKTXzgGzAUR5hJxujyJQ==" + }, + "node_modules/before-after-hook": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.3.tgz", + "integrity": "sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ==" + }, + "node_modules/clean-git-ref": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/clean-git-ref/-/clean-git-ref-2.0.1.tgz", + "integrity": "sha512-bLSptAy2P0s6hU4PzuIMKmMJJSE6gLXGH1cntDu7bWJUksvuM+7ReOK61mozULErYvP6a15rnYl0zFDef+pyPw==" + }, + "node_modules/crc-32": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz", + "integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==", + "bin": { + "crc32": "bin/crc32.njs" + }, + "engines": { + "node": ">=0.8" + } + }, + "node_modules/decompress-response": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", + "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", + "dependencies": { + "mimic-response": "^3.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/deprecation": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz", + "integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==" + }, + "node_modules/diff3": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/diff3/-/diff3-0.0.3.tgz", + "integrity": "sha512-iSq8ngPOt0K53A6eVr4d5Kn6GNrM2nQZtC740pzIriHtn4pOQ2lyzEXQMBeVcWERN0ye7fhBsk9PbLLQOnUx/g==" + }, + "node_modules/ignore": { + "version": "5.2.4", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", + "integrity": "sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==", + "engines": { + "node": ">= 4" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "node_modules/is-plain-object": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz", + "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/isomorphic-git": { + "version": "1.21.0", + "resolved": "https://registry.npmjs.org/isomorphic-git/-/isomorphic-git-1.21.0.tgz", + "integrity": "sha512-ZqCAUM63CYepA3fB8H7NVyPSiOkgzIbQ7T+QPrm9xtYgQypN9JUJ5uLMjB5iTfomdJf3mdm6aSxjZwnT6ubvEA==", + "dependencies": { + "async-lock": "^1.1.0", + "clean-git-ref": "^2.0.1", + "crc-32": "^1.2.0", + "diff3": "0.0.3", + "ignore": "^5.1.4", + "minimisted": "^2.0.0", + "pako": "^1.0.10", + "pify": "^4.0.1", + "readable-stream": "^3.4.0", + "sha.js": "^2.4.9", + "simple-get": "^4.0.1" + }, + "bin": { + "isogit": "cli.cjs" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/mimic-response": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", + "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/minimisted": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/minimisted/-/minimisted-2.0.1.tgz", + "integrity": "sha512-1oPjfuLQa2caorJUM8HV8lGgWCc0qqAO1MNv/k05G4qslmsndV/5WdNZrqCiyqiz3wohia2Ij2B7w2Dr7/IyrA==", + "dependencies": { + "minimist": "^1.2.5" + } + }, + "node_modules/node-fetch": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.9.tgz", + "integrity": "sha512-DJm/CJkZkRjKKj4Zi4BsKVZh3ValV5IR5s7LVZnW+6YMh0W1BfNA8XSs6DLMGYlId5F3KnA70uu2qepcR08Qqg==", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/pako": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz", + "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==" + }, + "node_modules/pify": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", + "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==", + "engines": { + "node": ">=6" + } + }, + "node_modules/readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/sha.js": { + "version": "2.4.11", + "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", + "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", + "dependencies": { + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" + }, + "bin": { + "sha.js": "bin.js" + } + }, + "node_modules/simple-concat": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz", + "integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/simple-get": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-4.0.1.tgz", + "integrity": "sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "decompress-response": "^6.0.0", + "once": "^1.3.1", + "simple-concat": "^1.0.0" + } + }, + "node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + }, + "node_modules/tunnel": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz", + "integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==", + "engines": { + "node": ">=0.6.11 <=0.7.0 || >=0.7.3" + } + }, + "node_modules/universal-user-agent": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz", + "integrity": "sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w==" + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" + }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "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", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + } + }, + "dependencies": { + "@actions/github": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@actions/github/-/github-5.1.1.tgz", + "integrity": "sha512-Nk59rMDoJaV+mHCOJPXuvB1zIbomlKS0dmSIqPGxd0enAXBnOfn4VWF+CGtRCwXZG9Epa54tZA7VIRlJDS8A6g==", + "requires": { + "@actions/http-client": "^2.0.1", + "@octokit/core": "^3.6.0", + "@octokit/plugin-paginate-rest": "^2.17.0", + "@octokit/plugin-rest-endpoint-methods": "^5.13.0" + } + }, + "@actions/http-client": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.1.tgz", + "integrity": "sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==", + "requires": { + "tunnel": "^0.0.6" + } + }, + "@octokit/auth-token": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-2.5.0.tgz", + "integrity": "sha512-r5FVUJCOLl19AxiuZD2VRZ/ORjp/4IN98Of6YJoJOkY75CIBuYfmiNHGrDwXr+aLGG55igl9QrxX3hbiXlLb+g==", + "requires": { + "@octokit/types": "^6.0.3" + } + }, + "@octokit/core": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/@octokit/core/-/core-3.6.0.tgz", + "integrity": "sha512-7RKRKuA4xTjMhY+eG3jthb3hlZCsOwg3rztWh75Xc+ShDWOfDDATWbeZpAHBNRpm4Tv9WgBMOy1zEJYXG6NJ7Q==", + "requires": { + "@octokit/auth-token": "^2.4.4", + "@octokit/graphql": "^4.5.8", + "@octokit/request": "^5.6.3", + "@octokit/request-error": "^2.0.5", + "@octokit/types": "^6.0.3", + "before-after-hook": "^2.2.0", + "universal-user-agent": "^6.0.0" + } + }, + "@octokit/endpoint": { + "version": "6.0.12", + "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-6.0.12.tgz", + "integrity": "sha512-lF3puPwkQWGfkMClXb4k/eUT/nZKQfxinRWJrdZaJO85Dqwo/G0yOC434Jr2ojwafWJMYqFGFa5ms4jJUgujdA==", + "requires": { + "@octokit/types": "^6.0.3", + "is-plain-object": "^5.0.0", + "universal-user-agent": "^6.0.0" + } + }, + "@octokit/graphql": { + "version": "4.8.0", + "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-4.8.0.tgz", + "integrity": "sha512-0gv+qLSBLKF0z8TKaSKTsS39scVKF9dbMxJpj3U0vC7wjNWFuIpL/z76Qe2fiuCbDRcJSavkXsVtMS6/dtQQsg==", + "requires": { + "@octokit/request": "^5.6.0", + "@octokit/types": "^6.0.3", + "universal-user-agent": "^6.0.0" + } + }, + "@octokit/openapi-types": { + "version": "12.11.0", + "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-12.11.0.tgz", + "integrity": "sha512-VsXyi8peyRq9PqIz/tpqiL2w3w80OgVMwBHltTml3LmVvXiphgeqmY9mvBw9Wu7e0QWk/fqD37ux8yP5uVekyQ==" + }, + "@octokit/plugin-paginate-rest": { + "version": "2.21.3", + "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.21.3.tgz", + "integrity": "sha512-aCZTEf0y2h3OLbrgKkrfFdjRL6eSOo8komneVQJnYecAxIej7Bafor2xhuDJOIFau4pk0i/P28/XgtbyPF0ZHw==", + "requires": { + "@octokit/types": "^6.40.0" + } + }, + "@octokit/plugin-rest-endpoint-methods": { + "version": "5.16.2", + "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-5.16.2.tgz", + "integrity": "sha512-8QFz29Fg5jDuTPXVtey05BLm7OB+M8fnvE64RNegzX7U+5NUXcOcnpTIK0YfSHBg8gYd0oxIq3IZTe9SfPZiRw==", + "requires": { + "@octokit/types": "^6.39.0", + "deprecation": "^2.3.1" + } + }, + "@octokit/request": { + "version": "5.6.3", + "resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.6.3.tgz", + "integrity": "sha512-bFJl0I1KVc9jYTe9tdGGpAMPy32dLBXXo1dS/YwSCTL/2nd9XeHsY616RE3HPXDVk+a+dBuzyz5YdlXwcDTr2A==", + "requires": { + "@octokit/endpoint": "^6.0.1", + "@octokit/request-error": "^2.1.0", + "@octokit/types": "^6.16.1", + "is-plain-object": "^5.0.0", + "node-fetch": "^2.6.7", + "universal-user-agent": "^6.0.0" + } + }, + "@octokit/request-error": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-2.1.0.tgz", + "integrity": "sha512-1VIvgXxs9WHSjicsRwq8PlR2LR2x6DwsJAaFgzdi0JfJoGSO8mYI/cHJQ+9FbN21aa+DrgNLnwObmyeSC8Rmpg==", + "requires": { + "@octokit/types": "^6.0.3", + "deprecation": "^2.0.0", + "once": "^1.4.0" + } + }, + "@octokit/types": { + "version": "6.41.0", + "resolved": "https://registry.npmjs.org/@octokit/types/-/types-6.41.0.tgz", + "integrity": "sha512-eJ2jbzjdijiL3B4PrSQaSjuF2sPEQPVCPzBvTHJD9Nz+9dw2SGH4K4xeQJ77YfTq5bRQ+bD8wT11JbeDPmxmGg==", + "requires": { + "@octokit/openapi-types": "^12.11.0" + } + }, + "async-lock": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/async-lock/-/async-lock-1.4.0.tgz", + "integrity": "sha512-coglx5yIWuetakm3/1dsX9hxCNox22h7+V80RQOu2XUUMidtArxKoZoOtHUPuR84SycKTXzgGzAUR5hJxujyJQ==" + }, + "before-after-hook": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.3.tgz", + "integrity": "sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ==" + }, + "clean-git-ref": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/clean-git-ref/-/clean-git-ref-2.0.1.tgz", + "integrity": "sha512-bLSptAy2P0s6hU4PzuIMKmMJJSE6gLXGH1cntDu7bWJUksvuM+7ReOK61mozULErYvP6a15rnYl0zFDef+pyPw==" + }, + "crc-32": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz", + "integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==" + }, + "decompress-response": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", + "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", + "requires": { + "mimic-response": "^3.1.0" + } + }, + "deprecation": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz", + "integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==" + }, + "diff3": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/diff3/-/diff3-0.0.3.tgz", + "integrity": "sha512-iSq8ngPOt0K53A6eVr4d5Kn6GNrM2nQZtC740pzIriHtn4pOQ2lyzEXQMBeVcWERN0ye7fhBsk9PbLLQOnUx/g==" + }, + "ignore": { + "version": "5.2.4", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", + "integrity": "sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==" + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "is-plain-object": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz", + "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==" + }, + "isomorphic-git": { + "version": "1.21.0", + "resolved": "https://registry.npmjs.org/isomorphic-git/-/isomorphic-git-1.21.0.tgz", + "integrity": "sha512-ZqCAUM63CYepA3fB8H7NVyPSiOkgzIbQ7T+QPrm9xtYgQypN9JUJ5uLMjB5iTfomdJf3mdm6aSxjZwnT6ubvEA==", + "requires": { + "async-lock": "^1.1.0", + "clean-git-ref": "^2.0.1", + "crc-32": "^1.2.0", + "diff3": "0.0.3", + "ignore": "^5.1.4", + "minimisted": "^2.0.0", + "pako": "^1.0.10", + "pify": "^4.0.1", + "readable-stream": "^3.4.0", + "sha.js": "^2.4.9", + "simple-get": "^4.0.1" + } + }, + "mimic-response": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", + "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==" + }, + "minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==" + }, + "minimisted": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/minimisted/-/minimisted-2.0.1.tgz", + "integrity": "sha512-1oPjfuLQa2caorJUM8HV8lGgWCc0qqAO1MNv/k05G4qslmsndV/5WdNZrqCiyqiz3wohia2Ij2B7w2Dr7/IyrA==", + "requires": { + "minimist": "^1.2.5" + } + }, + "node-fetch": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.9.tgz", + "integrity": "sha512-DJm/CJkZkRjKKj4Zi4BsKVZh3ValV5IR5s7LVZnW+6YMh0W1BfNA8XSs6DLMGYlId5F3KnA70uu2qepcR08Qqg==", + "requires": { + "whatwg-url": "^5.0.0" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "requires": { + "wrappy": "1" + } + }, + "pako": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz", + "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==" + }, + "pify": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", + "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==" + }, + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + }, + "safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" + }, + "sha.js": { + "version": "2.4.11", + "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", + "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", + "requires": { + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" + } + }, + "simple-concat": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz", + "integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==" + }, + "simple-get": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-4.0.1.tgz", + "integrity": "sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==", + "requires": { + "decompress-response": "^6.0.0", + "once": "^1.3.1", + "simple-concat": "^1.0.0" + } + }, + "string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "requires": { + "safe-buffer": "~5.2.0" + } + }, + "tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + }, + "tunnel": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz", + "integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==" + }, + "universal-user-agent": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz", + "integrity": "sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w==" + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" + }, + "webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + }, + "whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "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", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + } + } +} diff --git a/yarn2npm/package.json b/yarn2npm/package.json new file mode 100644 index 0000000..3c6cd73 --- /dev/null +++ b/yarn2npm/package.json @@ -0,0 +1,14 @@ +{ + "name": "yarn2npm", + "version": "1.0.0", + "description": "convert yarn to npm", + "main": "yarn2npm.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "Cameron Griffin", + "dependencies": { + "@actions/github": "^5.1.1", + "isomorphic-git": "^1.21.0" + } +} diff --git a/yarn2npm/yarn2npm.js b/yarn2npm/yarn2npm.js new file mode 100644 index 0000000..5c3d746 --- /dev/null +++ b/yarn2npm/yarn2npm.js @@ -0,0 +1,97 @@ +const {execSync} = require('child_process') + +const git = require('isomorphic-git'); +const http = require('isomorphic-git/http/node'); +const gitHubAuthFunct = () => { return { username: process.env.GITHUB_AUTH_TOKEN, password: '' }; }; + +const org = 'jupiterone'; +const repo = process.argv.slice(2); +const prbranch = "yarn2npm-patch1"; + +const tmpDir="yarn2npm_tmp"; +const fs = require('fs'); +const dir = `${tmpDir}/${repo}`; +const backupDir = `${tmpDir}/${repo}/yarn2npm`; + +const main = async () => { + try { + + //Create tmp working + if (!fs.existsSync(tmpDir)){ + fs.mkdirSync(tmpDir); + } + + //Create github branch + await createYarn2NpmBranch(repo, dir, org) + + //Create backup dir + if (!fs.existsSync(backupDir)){ + fs.mkdirSync(backupDir); + } + + //Backup package.json + fs.copyFile(`${dir}/package.json`, `${backupDir}/package.json`, (err) => { + if (err) throw err; + }); + + //remove yarn.lock + fs.unlink(`${dir}/yarn.lock`, (err) => { + if (err) throw err; + }); + + var currentPath = process.cwd(); + process.chdir(dir); + console.log(`Running npm install`); + try{ + execSync('npm install', {stdio: 'inherit'}, function(error) { + if (error) { + console.log(`exit: ${error.code}`); + } + }); + } + catch(e){ + console.log(`Error. Creating lock file ${backupDir}/failed.lock`); + fs.closeSync(fs.openSync(`${currentPath}/${backupDir}/failed.lock`, 'a')); + } + + return []; + } catch (e) { + console.log(`Error ${e}`); + } +} + +async function createYarn2NpmBranch (repo, dir, org, branch = prbranch) { + console.log(`Cloning Repo ${org}/${repo}...`); + await cloneRepo(repo, dir, org); + console.log(`Creating branch ${branch} for ${repo}...`); + await checkoutBranch(dir, branch); + return branch; +} + +async function cloneRepo (repo, dir, org) { + console.log(`Cloning https://github.com/${org}/${repo}`) + try { + await git.clone({ + fs, + http, + dir, + url: `https://github.com/${org}/${repo}`, + onAuth: gitHubAuthFunct, + singleBranch: true, + depth: 2 + }); + } catch (e) { + console.log(`error here 2: ${e}}`); + } +} + +async function checkoutBranch (dir, ref) { + await git.branch({ + fs, + dir, + ref, + checkout: true + }); +} + +main() \ No newline at end of file From 22e955af03f694eacf5a6ab356cdcff5b86a70a0 Mon Sep 17 00:00:00 2001 From: Cameron Griffin Date: Thu, 23 Feb 2023 13:05:45 -0500 Subject: [PATCH 2/8] backed up npm log files --- yarn2npm/yarn2npm.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/yarn2npm/yarn2npm.js b/yarn2npm/yarn2npm.js index 5c3d746..2698a47 100644 --- a/yarn2npm/yarn2npm.js +++ b/yarn2npm/yarn2npm.js @@ -10,9 +10,12 @@ const prbranch = "yarn2npm-patch1"; const tmpDir="yarn2npm_tmp"; const fs = require('fs'); +const path = require("path"); const dir = `${tmpDir}/${repo}`; const backupDir = `${tmpDir}/${repo}/yarn2npm`; + + const main = async () => { try { @@ -50,10 +53,24 @@ const main = async () => { }); } catch(e){ - console.log(`Error. Creating lock file ${backupDir}/failed.lock`); + console.log(`Error running npm install. Creating lock file ${backupDir}/failed.lock`); fs.closeSync(fs.openSync(`${currentPath}/${backupDir}/failed.lock`, 'a')); } + //Grab the npm log + const npmlogDir = (`${require('os').homedir()}/.npm/_logs/`); + const newestLog = (fs.readdirSync(npmlogDir) + .filter((file) => fs.lstatSync(path.join(npmlogDir, file)).isFile()) + .map((file) => ({ file, mtime: fs.lstatSync(path.join(npmlogDir, file)).mtime })) + .sort((a, b) => b.mtime.getTime() - a.mtime.getTime()))[0].file; + + console.log(`Backing up npm logs`); + fs.copyFile (`${npmlogDir}/${newestLog}`, `${currentPath}/${backupDir}/${newestLog}`, (err) => { + if (err) throw err; + }); + + //Find and replace yarn commands + return []; } catch (e) { console.log(`Error ${e}`); From a5995071529a1fc6be4cea40a555891df1f54cf2 Mon Sep 17 00:00:00 2001 From: Cameron Griffin Date: Tue, 7 Mar 2023 10:59:17 -0500 Subject: [PATCH 3/8] added code to replace yarn with npm run --- yarn2npm/yarn2npm.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/yarn2npm/yarn2npm.js b/yarn2npm/yarn2npm.js index 2698a47..8bc2565 100644 --- a/yarn2npm/yarn2npm.js +++ b/yarn2npm/yarn2npm.js @@ -27,6 +27,11 @@ const main = async () => { //Create github branch await createYarn2NpmBranch(repo, dir, org) + if (fs.existsSync(`${dir}/package-lock.json`)){ + console.log(`${repo} is already configured for npm`); + return[]; + } + //Create backup dir if (!fs.existsSync(backupDir)){ fs.mkdirSync(backupDir); @@ -70,6 +75,16 @@ const main = async () => { }); //Find and replace yarn commands + onsole.log(`Replacing yarn commands with npm`); + const packageFile = fs.readFileSync(`package.json`, { + encoding: 'utf8', + flag: 'r', + }) + .toString().replace(/yarn/g,'npm run') + + fs.writeFile(`package.json`, packageFile, 'utf8', function (err) { + if (err) return console.log(err); + }); return []; } catch (e) { From f389d7ca956dce3813662cde15066e4503b9dff2 Mon Sep 17 00:00:00 2001 From: Cameron Griffin Date: Tue, 7 Mar 2023 12:55:18 -0500 Subject: [PATCH 4/8] pushes back to repo --- yarn2npm/yarn2npm.js | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/yarn2npm/yarn2npm.js b/yarn2npm/yarn2npm.js index 8bc2565..e1af293 100644 --- a/yarn2npm/yarn2npm.js +++ b/yarn2npm/yarn2npm.js @@ -6,7 +6,7 @@ const gitHubAuthFunct = () => { return { username: process.env.GITHUB_AUTH_TOKEN const org = 'jupiterone'; const repo = process.argv.slice(2); -const prbranch = "yarn2npm-patch1"; +const prbranch = "yarn2npm-patch-1"; const tmpDir="yarn2npm_tmp"; const fs = require('fs'); @@ -75,7 +75,7 @@ const main = async () => { }); //Find and replace yarn commands - onsole.log(`Replacing yarn commands with npm`); + console.log(`Replacing yarn commands with npm`); const packageFile = fs.readFileSync(`package.json`, { encoding: 'utf8', flag: 'r', @@ -86,12 +86,37 @@ const main = async () => { if (err) return console.log(err); }); + // Check to see if changes needs to be pushed + await pushChanges(`${currentPath}/${dir}`); + return []; } catch (e) { console.log(`Error ${e}`); } } +async function pushChanges (dir) { + console.log(`Pushing changes`); + await git.commit({ + fs, + dir, + author: { + name: 'J1 Security', + email: 'security@jupiterone.com' + }, + message: 'Updating yarn to npm' + }); + + await git.push({ + fs, + http, + dir, + remote: 'origin', + force: true, + onAuth: gitHubAuthFunct + }); +} + async function createYarn2NpmBranch (repo, dir, org, branch = prbranch) { console.log(`Cloning Repo ${org}/${repo}...`); await cloneRepo(repo, dir, org); From 0547906e10a707af7375a0083e3ba61a1deffdc1 Mon Sep 17 00:00:00 2001 From: Cameron Griffin Date: Thu, 9 Mar 2023 18:08:12 -0500 Subject: [PATCH 5/8] full test to git push. added test.js to ignore file --- .gitignore | 2 ++ yarn2npm/yarn2npm.js | 53 ++++++++++++++++++++++++++------------------ 2 files changed, 34 insertions(+), 21 deletions(-) diff --git a/.gitignore b/.gitignore index 3579d87..fcfe5cf 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ results results.json bulkDelete.json + +test.js \ No newline at end of file diff --git a/yarn2npm/yarn2npm.js b/yarn2npm/yarn2npm.js index e1af293..17c7ee8 100644 --- a/yarn2npm/yarn2npm.js +++ b/yarn2npm/yarn2npm.js @@ -5,51 +5,57 @@ const http = require('isomorphic-git/http/node'); const gitHubAuthFunct = () => { return { username: process.env.GITHUB_AUTH_TOKEN, password: '' }; }; const org = 'jupiterone'; -const repo = process.argv.slice(2); +const repoName = process.argv.slice(2); const prbranch = "yarn2npm-patch-1"; -const tmpDir="yarn2npm_tmp"; +const repoPath= './yarn2npm_tmp'; const fs = require('fs'); const path = require("path"); -const dir = `${tmpDir}/${repo}`; -const backupDir = `${tmpDir}/${repo}/yarn2npm`; +const dir = `${repoPath}/${repoName}`; +const backupDir = 'yarn2npm'; const main = async () => { try { + const origPath = process.cwd(); //Create tmp working - if (!fs.existsSync(tmpDir)){ - fs.mkdirSync(tmpDir); + if (!fs.existsSync(repoPath)){ + fs.mkdirSync(repoPath); } //Create github branch - await createYarn2NpmBranch(repo, dir, org) + await createYarn2NpmBranch(repoName, dir, org) if (fs.existsSync(`${dir}/package-lock.json`)){ - console.log(`${repo} is already configured for npm`); + console.log(`${repoName} is already configured for npm`); return[]; } //Create backup dir - if (!fs.existsSync(backupDir)){ - fs.mkdirSync(backupDir); + if (!fs.existsSync(`${dir}/${backupDir}`)){ + fs.mkdirSync(`${dir}/${backupDir}`); } //Backup package.json - fs.copyFile(`${dir}/package.json`, `${backupDir}/package.json`, (err) => { + let copyFile = 'orig-package.json'; + console.log(`Backing up package.json to ${copyFile}`); + fs.copyFile(`${dir}/package.json`, `${dir}/${backupDir}/${copyFile}`, (err) => { if (err) throw err; }); - + await git.add({ fs, dir, filepath: `${backupDir}/${copyFile}` }); + //remove yarn.lock + console.log(`Removing yarn.lock`); fs.unlink(`${dir}/yarn.lock`, (err) => { if (err) throw err; }); + await git.remove({ fs, dir, filepath: 'yarn.lock' }); - var currentPath = process.cwd(); - process.chdir(dir); + //npm install console.log(`Running npm install`); + process.chdir(dir); try{ execSync('npm install', {stdio: 'inherit'}, function(error) { if (error) { @@ -59,8 +65,12 @@ const main = async () => { } catch(e){ console.log(`Error running npm install. Creating lock file ${backupDir}/failed.lock`); - fs.closeSync(fs.openSync(`${currentPath}/${backupDir}/failed.lock`, 'a')); + fs.closeSync(fs.openSync(`${origPath}/${backupDir}/failed.lock`, 'a')); + await git.add({ fs, dir: `${origPath}/${backupDir}`, filepath: 'failed.lock' }); } + process.chdir(origPath); + await git.add({ fs, dir, filepath: 'package-lock.json' }); + //Grab the npm log const npmlogDir = (`${require('os').homedir()}/.npm/_logs/`); @@ -70,24 +80,25 @@ const main = async () => { .sort((a, b) => b.mtime.getTime() - a.mtime.getTime()))[0].file; console.log(`Backing up npm logs`); - fs.copyFile (`${npmlogDir}/${newestLog}`, `${currentPath}/${backupDir}/${newestLog}`, (err) => { + fs.copyFile (`${npmlogDir}/${newestLog}`, `${dir}/${backupDir}/${newestLog}`, (err) => { if (err) throw err; }); + await git.add({ fs, dir, filepath: `${backupDir}/${newestLog }` }); //Find and replace yarn commands console.log(`Replacing yarn commands with npm`); - const packageFile = fs.readFileSync(`package.json`, { + const packageFile = fs.readFileSync(`${dir}/package.json`, { encoding: 'utf8', flag: 'r', }) .toString().replace(/yarn/g,'npm run') - fs.writeFile(`package.json`, packageFile, 'utf8', function (err) { + fs.writeFile(`${dir}/package.json`, packageFile, 'utf8', function (err) { if (err) return console.log(err); }); - - // Check to see if changes needs to be pushed - await pushChanges(`${currentPath}/${dir}`); + await git.add({ fs, dir, filepath: 'package.json' }); + + await pushChanges(dir); return []; } catch (e) { From 677a390a8791212a61b422f5e0261567954b1671 Mon Sep 17 00:00:00 2001 From: Cameron Griffin Date: Fri, 10 Mar 2023 11:44:17 -0500 Subject: [PATCH 6/8] Removed tmpdir from script. Added readme. --- yarn2npm/README.md | 31 +++++++++++++++++++++++++++++++ yarn2npm/package-lock.json | 1 - yarn2npm/yarn2npm.js | 10 ++-------- 3 files changed, 33 insertions(+), 9 deletions(-) create mode 100644 yarn2npm/README.md diff --git a/yarn2npm/README.md b/yarn2npm/README.md new file mode 100644 index 0000000..0bfcbb7 --- /dev/null +++ b/yarn2npm/README.md @@ -0,0 +1,31 @@ +# Yarn to NPM script + +This script will convert a project from yarn to npm. + +## Building + +Install dependencies and build with: + +``` +npm install +``` + +## Running the script + +You must set the following ENV vars: + +``` +GITHUB_AUTH_TOKEN= +``` + +Run the script from within a temp directory + +``` +cameron@laptop Code % git clone git@github.com:JupiterOne/secops-automation-examples.git +cameron@laptop Code % mkdir tmpDir +cameron@laptop Code % cd tmpDir +cgriffin@cgriffin-MBP tmpDir % node ../secops-automation-examples/yarn2npm/yarn2npm.js test-aut-web-juno +``` + +A new branch will be created in the repo specified. Log files will be stored in a yarn2npm folder. Please remove these before +pushing changes to main. If there was a problem running npm install, a failure.lock will be present in the yarn2npm folder. diff --git a/yarn2npm/package-lock.json b/yarn2npm/package-lock.json index 983fe0d..9d6f269 100644 --- a/yarn2npm/package-lock.json +++ b/yarn2npm/package-lock.json @@ -7,7 +7,6 @@ "": { "name": "yarn2npm", "version": "1.0.0", - "license": "ISC", "dependencies": { "@actions/github": "^5.1.1", "isomorphic-git": "^1.21.0" diff --git a/yarn2npm/yarn2npm.js b/yarn2npm/yarn2npm.js index 17c7ee8..37ee0bd 100644 --- a/yarn2npm/yarn2npm.js +++ b/yarn2npm/yarn2npm.js @@ -5,13 +5,12 @@ const http = require('isomorphic-git/http/node'); const gitHubAuthFunct = () => { return { username: process.env.GITHUB_AUTH_TOKEN, password: '' }; }; const org = 'jupiterone'; -const repoName = process.argv.slice(2); const prbranch = "yarn2npm-patch-1"; -const repoPath= './yarn2npm_tmp'; const fs = require('fs'); const path = require("path"); -const dir = `${repoPath}/${repoName}`; +const repoName = process.argv.slice(2); +const dir = `./${repoName}`; const backupDir = 'yarn2npm'; @@ -19,11 +18,6 @@ const backupDir = 'yarn2npm'; const main = async () => { try { const origPath = process.cwd(); - - //Create tmp working - if (!fs.existsSync(repoPath)){ - fs.mkdirSync(repoPath); - } //Create github branch await createYarn2NpmBranch(repoName, dir, org) From 27c9db48cfb8a1229c6439afd1eb18623c442a98 Mon Sep 17 00:00:00 2001 From: Cameron Griffin Date: Fri, 10 Mar 2023 11:55:24 -0500 Subject: [PATCH 7/8] Update README.md --- yarn2npm/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/yarn2npm/README.md b/yarn2npm/README.md index 0bfcbb7..ce658f3 100644 --- a/yarn2npm/README.md +++ b/yarn2npm/README.md @@ -22,6 +22,8 @@ Run the script from within a temp directory ``` cameron@laptop Code % git clone git@github.com:JupiterOne/secops-automation-examples.git +cameron@laptop Code % cd secops-automation-examples/yarn2npm/ && npm install +cameron@laptop Code % cd ../../ cameron@laptop Code % mkdir tmpDir cameron@laptop Code % cd tmpDir cgriffin@cgriffin-MBP tmpDir % node ../secops-automation-examples/yarn2npm/yarn2npm.js test-aut-web-juno From aad344e3c3ab5c993c9c11df64c26854764c970f Mon Sep 17 00:00:00 2001 From: Cameron Griffin Date: Wed, 29 Mar 2023 12:37:12 -0400 Subject: [PATCH 8/8] fixed missing semicolons per codeql --- yarn2npm/yarn2npm.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yarn2npm/yarn2npm.js b/yarn2npm/yarn2npm.js index 37ee0bd..20451d8 100644 --- a/yarn2npm/yarn2npm.js +++ b/yarn2npm/yarn2npm.js @@ -20,7 +20,7 @@ const main = async () => { const origPath = process.cwd(); //Create github branch - await createYarn2NpmBranch(repoName, dir, org) + await createYarn2NpmBranch(repoName, dir, org); if (fs.existsSync(`${dir}/package-lock.json`)){ console.log(`${repoName} is already configured for npm`); @@ -85,7 +85,7 @@ const main = async () => { encoding: 'utf8', flag: 'r', }) - .toString().replace(/yarn/g,'npm run') + .toString().replace(/yarn/g,'npm run'); fs.writeFile(`${dir}/package.json`, packageFile, 'utf8', function (err) { if (err) return console.log(err);