lerna-publisher
Advanced tools
Comparing version 1.0.11 to 1.0.12
#!/usr/bin/env node | ||
export {}; | ||
export declare function getRepoAndOrg(githubLink: string): Promise<string[]>; | ||
export declare function runDeployCommand(folder: string, pkgname: string): Promise<void>; | ||
//# sourceMappingURL=cli.d.ts.map |
@@ -10,5 +10,23 @@ #!/usr/bin/env node | ||
const publish_lerna_1 = require("./publish_lerna"); | ||
const aws_1 = require("./aws"); | ||
const github_1 = require("./github"); | ||
const getPackages = require('get-monorepo-packages'); | ||
const { version, description } = require('../package.json'); | ||
process.on('unhandledRejection', printErrorAndExit); | ||
commander_1.default | ||
.command('publish [folder]') // sub-command name | ||
.description('publish all unpublish pacakges') // command description | ||
// function to execute when command is uses | ||
.action((folder) => { | ||
runPublishCommand(folder); | ||
}); | ||
commander_1.default | ||
.command('deploydemo [pkgName] [folder]') // sub-command name | ||
.description('Deploy package for demo usage') // command description | ||
// function to execute when command is uses | ||
.action((pkgName, folder) => { | ||
console.log(pkgName, folder); | ||
runDeployCommand(folder, pkgName); | ||
}); | ||
commander_1.default | ||
.version(version, '-v, --version') | ||
@@ -19,12 +37,63 @@ .description(description) | ||
.parse(process.argv); | ||
const { args } = commander_1.default; | ||
async function getWorkingFolder(cmdargs) { | ||
// const { | ||
// args | ||
// } = program | ||
async function getWorkingFolder(pathToFolder) { | ||
let pathToProject = process.cwd(); | ||
if (arguments.length !== 0 && cmdargs[0] !== '') { | ||
pathToProject = path_1.default.resolve(cmdargs[0]); | ||
if (pathToFolder !== '' && pathToFolder !== undefined) { | ||
pathToProject = path_1.default.resolve(pathToFolder); | ||
} | ||
return pathToProject; | ||
} | ||
async function runTheCommand() { | ||
const pathToProject = await getWorkingFolder(args); | ||
async function getRepoAndOrg(githubLink) { | ||
// git@github.com:wixplosives/lerna-publisher.git | ||
let parts = githubLink.split(':'); | ||
parts = parts[1].split('.'); | ||
parts = parts[0].split('/'); | ||
return parts; | ||
} | ||
exports.getRepoAndOrg = getRepoAndOrg; | ||
async function runDeployCommand(folder, pkgname) { | ||
console.log('Deploy ', pkgname, 'from', folder); | ||
let prNum = 0; | ||
const varValue = process.env.TRAVIS_PULL_REQUEST; | ||
let result = true; | ||
if (varValue === 'false' || varValue === undefined) { | ||
console.log('Not a pull request.Nothing to deploy.'); | ||
process.exit(0); | ||
} | ||
else { | ||
prNum = parseInt(varValue, 10); | ||
} | ||
const pathToProject = await getWorkingFolder(folder); | ||
const packages = getPackages(pathToProject); | ||
const pkgToDeploy = packages.find((element) => { | ||
return element.package.name === pkgname; | ||
}); | ||
const bucketName = process.env.AWS_BUCKET_NAME || ''; | ||
const branchName = process.env.TRAVIS_BRANCH || ''; | ||
const bucketLink = `http://${bucketName}.s3-website-us-east-1.amazonaws.com`; | ||
const githubToken = process.env.GITHUB_TOKEN || ''; | ||
const githubSlug = process.env.TRAVIS_REPO_SLUG || ''; | ||
const slugParts = githubSlug.split('/'); | ||
const repo = slugParts[1]; | ||
const org = slugParts[0]; | ||
console.log('Deploy package from folder: ' + pkgToDeploy.location); | ||
const pathToPublish = path_1.default.join(pkgToDeploy.location, 'dist'); | ||
result = await aws_1.uploadFolder(pathToPublish, pkgToDeploy.package.name, branchName); | ||
console.debug('Upload folder to s3 result: ', result ? 'SUCCESS' : 'FAIL'); | ||
if (result) { | ||
const cureentToime = new Date(); | ||
const textToPublish = 'Demo server. Deployed at ' + cureentToime.toString(); | ||
const linkToPublish = 'http://' + path_1.default.join(bucketLink, pkgToDeploy.package.name, branchName); | ||
console.debug('Link to publish', linkToPublish); | ||
result = await github_1.postLinkToPRTest(textToPublish, linkToPublish, githubToken, org, repo, prNum); | ||
console.debug('Post link to PR result: ', result ? 'SUCCESS' : 'FAIL'); | ||
} | ||
console.log('Exiting', result ? 0 : 1); | ||
process.exit(result ? 0 : 1); | ||
} | ||
exports.runDeployCommand = runDeployCommand; | ||
async function runPublishCommand(folder) { | ||
const pathToProject = await getWorkingFolder(folder); | ||
console.log('lerna-publisher starting in ' + pathToProject); | ||
@@ -40,3 +109,2 @@ const result = await publish_lerna_1.CheckAndPublishMonorepo(pathToProject).catch(printErrorAndExit); | ||
} | ||
runTheCommand(); | ||
function printErrorAndExit(message) { | ||
@@ -43,0 +111,0 @@ console.error(message); |
@@ -8,5 +8,7 @@ "use strict"; | ||
async function runPublishCommand(pathToFolder) { | ||
const cmdSetRegistry = 'npm config set registry https://registry.npmjs.org/'; | ||
const cmdText = 'yarn publish --ignore-scripts --non-interactive --verbose --no-git-tag-version'; | ||
let retVal = false; | ||
try { | ||
childProcess.execSync(cmdSetRegistry, { cwd: pathToFolder }); | ||
childProcess.execSync(cmdText, { cwd: pathToFolder }); | ||
@@ -13,0 +15,0 @@ retVal = true; |
{ | ||
"name": "lerna-publisher", | ||
"description": "Utility to publish lerna/yarn/workspace types of packages from ci to npm", | ||
"version": "1.0.11", | ||
"version": "1.0.12", | ||
"main": "cjs/index.js", | ||
@@ -17,2 +17,3 @@ "bin": { | ||
"dependencies": { | ||
"aws-sdk": "^2.384.0", | ||
"chalk": "^2.4.1", | ||
@@ -22,2 +23,4 @@ "child_process": "^1.0.2", | ||
"get-monorepo-packages": "^1.1.0", | ||
"github-api": "^3.0.0", | ||
"mime": "^2.4.0", | ||
"pacote": "^9.2.3" | ||
@@ -30,2 +33,3 @@ }, | ||
"@types/commander": "^2.12.2", | ||
"@types/mime": "^2.0.0", | ||
"@types/mocha": "^5.2.5", | ||
@@ -32,0 +36,0 @@ "@types/node": "8", |
@@ -16,3 +16,3 @@ [![Build Status](https://travis-ci.com/wixplosives/lerna-publisher.svg?branch=master)](https://travis-ci.com/wixplosives/lerna-publisher)[![npm version](https://badge.fury.io/js/lerna-publisher.svg)](https://badge.fury.io/js/lerna-publisher) | ||
## Example of Travis configuration | ||
### Example of Travis configuration | ||
@@ -38,3 +38,3 @@ Add NPM_TOKEN environment variable in Travis Build Settings | ||
## CLI Options | ||
### CLI Options | ||
@@ -46,4 +46,22 @@ ``` | ||
## Publish demo link for Pull Request in github | ||
You can use lerna-publisher to generate static demo sites for your pull requests. | ||
Environmnet variables | ||
1. GITHUB_TOKEN='your github token' | ||
1. TRAVIS_PULL_REQUEST - travis sets PR number here | ||
1. TRAVIS_BRANCH - travis sets branch name here | ||
1. AWS_BUCKET_NAME - name of the s3 bucket to upload you demo to 'demo.youdomain.demosites' | ||
1. AWS_ACCESS_KEY_ID='YOURAWSSECRETKEY' | ||
1. AWS_SECRET_ID='Yourawssecretid' | ||
Than run: | ||
``` | ||
lerna-publisher deploydemo @wix/lpt-server /Users/youruser/dev/lerna-publish-test | ||
``` | ||
### License | ||
MIT |
@@ -6,3 +6,6 @@ #!/usr/bin/env node | ||
import { CheckAndPublishMonorepo } from './publish_lerna' | ||
import { uploadFolder } from './aws' | ||
import { postLinkToPRTest } from './github' | ||
const getPackages = require( 'get-monorepo-packages' ) | ||
const { version, description } = require('../package.json') | ||
@@ -13,2 +16,19 @@ | ||
program | ||
.command('publish [folder]') // sub-command name | ||
.description('publish all unpublish pacakges') // command description | ||
// function to execute when command is uses | ||
.action( (folder: string) => { | ||
runPublishCommand(folder) | ||
}) | ||
program | ||
.command('deploydemo [pkgName] [folder]') // sub-command name | ||
.description('Deploy package for demo usage') // command description | ||
// function to execute when command is uses | ||
.action( ( pkgName: string, folder: string) => { | ||
console.log( pkgName, folder ) | ||
runDeployCommand(folder, pkgName) | ||
}) | ||
program | ||
.version(version, '-v, --version') | ||
@@ -20,11 +40,11 @@ .description(description) | ||
const { | ||
args | ||
} = program | ||
// const { | ||
// args | ||
// } = program | ||
async function getWorkingFolder( cmdargs: string[]) { | ||
async function getWorkingFolder( pathToFolder: string) { | ||
let pathToProject = process.cwd() | ||
if (arguments.length !== 0 && cmdargs[0] !== '') { | ||
pathToProject = path.resolve(cmdargs[0]) | ||
if ( pathToFolder !== '' && pathToFolder !== undefined) { | ||
pathToProject = path.resolve(pathToFolder) | ||
} | ||
@@ -34,4 +54,59 @@ return pathToProject | ||
async function runTheCommand() { | ||
const pathToProject = await getWorkingFolder(args) | ||
export async function getRepoAndOrg( githubLink: string ) { | ||
// git@github.com:wixplosives/lerna-publisher.git | ||
let parts = githubLink.split(':') | ||
parts = parts[1].split('.') | ||
parts = parts[0].split('/') | ||
return parts | ||
} | ||
export async function runDeployCommand(folder: string, pkgname: string) { | ||
console.log('Deploy ' , pkgname , 'from' , folder) | ||
let prNum = 0 | ||
const varValue = process.env.TRAVIS_PULL_REQUEST | ||
let result = true | ||
if ( varValue === 'false' || varValue === undefined ) { | ||
console.log('Not a pull request.Nothing to deploy.') | ||
process.exit( 0 ) | ||
} else { | ||
prNum = parseInt(varValue, 10) | ||
} | ||
const pathToProject = await getWorkingFolder(folder) | ||
const packages = getPackages(pathToProject) | ||
const pkgToDeploy = packages.find((element: { package: { name: string, version: string }, location: string}) => { | ||
return element.package.name === pkgname | ||
}) | ||
const bucketName = process.env.AWS_BUCKET_NAME || '' | ||
const branchName = process.env.TRAVIS_BRANCH || '' | ||
const bucketLink = `http://${bucketName}.s3-website-us-east-1.amazonaws.com` | ||
const githubToken = process.env.GITHUB_TOKEN || '' | ||
const githubSlug = process.env.TRAVIS_REPO_SLUG || '' | ||
const slugParts = githubSlug.split('/') | ||
const repo = slugParts[1] | ||
const org = slugParts[0] | ||
console.log('Deploy package from folder: ' + pkgToDeploy.location ) | ||
const pathToPublish = path.join(pkgToDeploy.location, 'dist') | ||
result = await uploadFolder(pathToPublish, pkgToDeploy.package.name, branchName) | ||
console.debug('Upload folder to s3 result: ', result ? 'SUCCESS' : 'FAIL') | ||
if ( result ) { | ||
const cureentToime = new Date() | ||
const textToPublish = 'Demo server. Deployed at ' + cureentToime.toString() | ||
const linkToPublish = 'http://' + path.join( bucketLink, | ||
pkgToDeploy.package.name, branchName ) | ||
console.debug('Link to publish',linkToPublish) | ||
result = await postLinkToPRTest(textToPublish, linkToPublish, | ||
githubToken, org, repo, | ||
prNum) | ||
console.debug('Post link to PR result: ', result ? 'SUCCESS' : 'FAIL') | ||
} | ||
console.log('Exiting', result ? 0 : 1) | ||
process.exit( result ? 0 : 1 ) | ||
} | ||
async function runPublishCommand(folder: string) { | ||
const pathToProject = await getWorkingFolder(folder) | ||
console.log('lerna-publisher starting in ' + pathToProject) | ||
@@ -48,4 +123,2 @@ | ||
runTheCommand() | ||
function printErrorAndExit(message: unknown) { | ||
@@ -52,0 +125,0 @@ console.error(message) |
@@ -8,5 +8,7 @@ | ||
async function runPublishCommand(pathToFolder: string) { | ||
const cmdSetRegistry = 'npm config set registry https://registry.npmjs.org/' | ||
const cmdText = 'yarn publish --ignore-scripts --non-interactive --verbose --no-git-tag-version' | ||
let retVal = false | ||
try { | ||
childProcess.execSync(cmdSetRegistry , {cwd: pathToFolder}) | ||
childProcess.execSync(cmdText , {cwd: pathToFolder}) | ||
@@ -13,0 +15,0 @@ retVal = true |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 7 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
37231
24
526
65
8
16
11
2
+ Addedaws-sdk@^2.384.0
+ Addedgithub-api@^3.0.0
+ Addedmime@^2.4.0
+ Addedavailable-typed-arrays@1.0.7(transitive)
+ Addedaws-sdk@2.1692.0(transitive)
+ Addedaxios@0.21.4(transitive)
+ Addedbase64-js@1.5.1(transitive)
+ Addedbuffer@4.9.2(transitive)
+ Addedcall-bind@1.0.8(transitive)
+ Addedcall-bind-apply-helpers@1.0.1(transitive)
+ Addedcall-bound@1.0.3(transitive)
+ Addeddebug@2.6.93.2.7(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addeddunder-proto@1.0.1(transitive)
+ Addedes-define-property@1.0.1(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedes-object-atoms@1.1.1(transitive)
+ Addedevents@1.1.1(transitive)
+ Addedfollow-redirects@1.15.9(transitive)
+ Addedfor-each@0.3.3(transitive)
+ Addedget-intrinsic@1.2.7(transitive)
+ Addedget-proto@1.0.1(transitive)
+ Addedgithub-api@3.4.0(transitive)
+ Addedgopd@1.2.0(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-symbols@1.1.0(transitive)
+ Addedhas-tostringtag@1.0.2(transitive)
+ Addedieee754@1.1.13(transitive)
+ Addedis-arguments@1.2.0(transitive)
+ Addedis-callable@1.2.7(transitive)
+ Addedis-generator-function@1.1.0(transitive)
+ Addedis-regex@1.2.1(transitive)
+ Addedis-typed-array@1.1.15(transitive)
+ Addedjmespath@0.16.0(transitive)
+ Addedjs-base64@2.6.4(transitive)
+ Addedmath-intrinsics@1.1.0(transitive)
+ Addedmime@2.6.0(transitive)
+ Addedms@2.1.3(transitive)
+ Addedpossible-typed-array-names@1.0.0(transitive)
+ Addedpunycode@1.3.2(transitive)
+ Addedquerystring@0.2.0(transitive)
+ Addedsafe-regex-test@1.1.0(transitive)
+ Addedsax@1.2.1(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedurl@0.10.3(transitive)
+ Addedutf8@2.1.2(transitive)
+ Addedutil@0.12.5(transitive)
+ Addeduuid@8.0.0(transitive)
+ Addedwhich-typed-array@1.1.18(transitive)
+ Addedxml2js@0.6.2(transitive)
+ Addedxmlbuilder@11.0.1(transitive)