New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

lerna-publisher

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lerna-publisher - npm Package Compare versions

Comparing version 1.0.11 to 1.0.12

cjs/aws.d.ts

3

cjs/cli.d.ts
#!/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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc