From 677a390a8791212a61b422f5e0261567954b1671 Mon Sep 17 00:00:00 2001 From: Cameron Griffin Date: Fri, 10 Mar 2023 11:44:17 -0500 Subject: [PATCH] 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)