Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@percy/agent

Package Overview
Dependencies
Maintainers
6
Versions
179
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@percy/agent - npm Package Compare versions

Comparing version 0.0.50 to 0.1.0

2

.oclif.manifest.json

@@ -1,1 +0,1 @@

{"version":"0.0.50","commands":{"exec":{"id":"exec","description":"Start and stop Percy around a supplied command","pluginName":"@percy/agent","pluginType":"core","hidden":false,"aliases":[],"examples":["$ percy exec -- echo \"percy is running around this echo command\"","$ percy exec -- bash -c \"echo foo && echo bar\""],"flags":{"port":{"name":"port","type":"option","char":"p","description":"port","default":5338},"network-idle-timeout":{"name":"network-idle-timeout","type":"option","char":"t","description":"asset discovery network idle timeout (in milliseconds)","default":50}},"args":[]},"finalize":{"id":"finalize","description":"finalize a build","pluginName":"@percy/agent","pluginType":"core","hidden":false,"aliases":[],"examples":["$ percy finalize --all\n[percy] Finalized parallel build."],"flags":{"all":{"name":"all","type":"boolean","char":"a","required":true,"allowNo":false}},"args":[]},"percy-command":{"id":"percy-command","pluginName":"@percy/agent","pluginType":"core","hidden":true,"aliases":[],"flags":{},"args":[]},"start":{"id":"start","description":"Starts the percy process.","pluginName":"@percy/agent","pluginType":"core","hidden":true,"aliases":[],"examples":["$ percy start\ninfo: percy has started on port 5338."],"flags":{"port":{"name":"port","type":"option","char":"p","description":"port","default":5338},"network-idle-timeout":{"name":"network-idle-timeout","type":"option","char":"t","description":"asset discovery network idle timeout (in milliseconds)","default":50},"detached":{"name":"detached","type":"boolean","char":"d","description":"start as a detached process","allowNo":false}},"args":[]},"stop":{"id":"stop","description":"Stops the percy process.","pluginName":"@percy/agent","pluginType":"core","hidden":true,"aliases":[],"examples":["$ percy stop\ninfo: percy has stopped."],"flags":{"port":{"name":"port","type":"option","char":"p","description":"port","default":5338}},"args":[]}}}
{"version":"0.1.0","commands":{"exec":{"id":"exec","description":"Start and stop Percy around a supplied command","pluginName":"@percy/agent","pluginType":"core","hidden":false,"aliases":[],"examples":["$ percy exec -- echo \"percy is running around this echo command\"","$ percy exec -- bash -c \"echo foo && echo bar\""],"flags":{"port":{"name":"port","type":"option","char":"p","description":"port","default":5338},"network-idle-timeout":{"name":"network-idle-timeout","type":"option","char":"t","description":"asset discovery network idle timeout (in milliseconds)","default":50}},"args":[]},"finalize":{"id":"finalize","description":"finalize a build","pluginName":"@percy/agent","pluginType":"core","hidden":false,"aliases":[],"examples":["$ percy finalize --all\n[percy] Finalized parallel build."],"flags":{"all":{"name":"all","type":"boolean","char":"a","required":true,"allowNo":false}},"args":[]},"percy-command":{"id":"percy-command","pluginName":"@percy/agent","pluginType":"core","hidden":true,"aliases":[],"flags":{},"args":[]},"start":{"id":"start","description":"Starts the percy process.","pluginName":"@percy/agent","pluginType":"core","hidden":true,"aliases":[],"examples":["$ percy start\ninfo: percy has started on port 5338."],"flags":{"port":{"name":"port","type":"option","char":"p","description":"port","default":5338},"network-idle-timeout":{"name":"network-idle-timeout","type":"option","char":"t","description":"asset discovery network idle timeout (in milliseconds)","default":50},"detached":{"name":"detached","type":"boolean","char":"d","description":"start as a detached process","allowNo":false}},"args":[]},"stop":{"id":"stop","description":"Stops the percy process.","pluginName":"@percy/agent","pluginType":"core","hidden":true,"aliases":[],"examples":["$ percy stop\ninfo: percy has stopped."],"flags":{"port":{"name":"port","type":"option","char":"p","description":"port","default":5338}},"args":[]}}}

@@ -20,7 +20,10 @@ "use strict";

}
await this.agentService.start({ port, networkIdleTimeout });
this.logStart();
if (this.percyWillRun()) {
await this.agentService.start({ port, networkIdleTimeout });
this.logStart();
}
// Even if Percy will not run, continue to run the subprocess
const spawnedProcess = child_process_1.spawn(command, argv, { stdio: 'inherit' });
spawnedProcess.on('exit', async (code) => {
if (!this.percyEnvVarsMissing()) {
if (this.percyWillRun()) {
await this.agentService.stop();

@@ -30,3 +33,2 @@ }

});
spawnedProcess.unref();
}

@@ -33,0 +35,0 @@ }

@@ -14,2 +14,5 @@ "use strict";

await super.run();
if (!this.percyWillRun()) {
this.exit(0);
}
this.parse(Finalize);

@@ -16,0 +19,0 @@ const result = await this.buildService.finalizeAll();

@@ -14,5 +14,5 @@ import { Command } from '@oclif/command';

percyEnabled(): boolean;
percyEnvVarsMissing(): boolean;
percyWillRun(): boolean;
percyTokenPresent(): boolean;
logStart(): void;
logMissingEnvVar(name: string): void;
}

@@ -16,8 +16,5 @@ "use strict";

async run() {
if (!this.percyEnabled()) {
this.exit(0);
if (this.percyEnabled && !this.percyTokenPresent()) {
this.warn('Skipping visual tests. PERCY_TOKEN was not provided.');
}
if (this.percyEnvVarsMissing()) {
this.exit(1);
}
}

@@ -27,17 +24,13 @@ percyEnabled() {

}
percyEnvVarsMissing() {
if (this.percyToken === '') {
this.logMissingEnvVar('PERCY_TOKEN');
return true;
}
return false;
percyWillRun() {
return (this.percyEnabled() && this.percyTokenPresent());
}
percyTokenPresent() {
return this.percyToken.trim() !== '';
}
logStart() {
this.logger.info('percy has started.');
}
logMissingEnvVar(name) {
this.error(`You must set ${name}`, { exit: 1 });
}
}
PercyCommand.hidden = true;
exports.default = PercyCommand;

@@ -10,2 +10,6 @@ "use strict";

await super.run();
// If Percy is disabled or is missing a token, gracefully exit here
if (!this.percyWillRun()) {
this.exit(0);
}
const { flags } = this.parse(Start);

@@ -12,0 +16,0 @@ let port = flags.port;

@@ -10,2 +10,6 @@ "use strict";

await super.run();
// If Percy is disabled or is missing a token, gracefully exit here
if (!this.percyWillRun()) {
this.exit(0);
}
const { flags } = this.parse(Stop);

@@ -12,0 +16,0 @@ const port = flags.port ? flags.port : 5338;

export declare class PercyAgentClient {
xhr: XMLHttpRequest;
constructor(xhr?: any);
post(url: string, data: any): void;
agentHost: string;
agentConnected: boolean;
constructor(agentHost: string, xhr?: any);
post(path: string, data: any): void;
healthCheck(): void;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class PercyAgentClient {
constructor(xhr) {
constructor(agentHost, xhr) {
this.agentConnected = false;
this.agentHost = agentHost;
this.xhr = new xhr() || new XMLHttpRequest();
this.healthCheck();
}
post(url, data) {
this.xhr.open('post', url, false); // synchronous request
post(path, data) {
if (!this.agentConnected) {
console.warn('percy agent not started.');
return;
}
this.xhr.open('post', `${this.agentHost}${path}`, false); // synchronous request
this.xhr.setRequestHeader('Content-Type', 'application/json');
this.xhr.send(JSON.stringify(data));
}
healthCheck() {
try {
this.xhr.open('get', `${this.agentHost}/percy/healthcheck`, false);
this.xhr.onload = () => {
if (this.xhr.status === 200) {
this.agentConnected = true;
}
};
this.xhr.send();
}
catch (_a) {
this.agentConnected = false;
}
}
}
exports.PercyAgentClient = PercyAgentClient;

@@ -0,1 +1,2 @@

import { PercyAgentClient } from './percy-agent-client';
import { SnapshotOptions } from './snapshot-options';

@@ -9,2 +10,3 @@ import { ClientOptions } from './client-options';

domTransformation: any | null;
client: PercyAgentClient;
readonly defaultDoctype: string;

@@ -11,0 +13,0 @@ constructor(options?: ClientOptions);

@@ -12,2 +12,3 @@ "use strict";

this.port = options.port || 5338;
this.client = new percy_agent_client_1.PercyAgentClient(`http://localhost:${this.port}`, this.xhr);
}

@@ -17,4 +18,3 @@ snapshot(name, options = {}) {

let domSnapshot = this.domSnapshot(documentObject);
let percyAgentClient = new percy_agent_client_1.PercyAgentClient(this.xhr);
percyAgentClient.post(`http://localhost:${this.port}/percy/snapshot`, {
this.client.post('/percy/snapshot', {
name,

@@ -21,0 +21,0 @@ url: documentObject.URL,

@@ -11,10 +11,31 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.PercyAgent = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){

class PercyAgentClient {
constructor(xhr) {
constructor(agentHost, xhr) {
this.agentConnected = false;
this.agentHost = agentHost;
this.xhr = new xhr() || new XMLHttpRequest();
this.healthCheck();
}
post(url, data) {
this.xhr.open('post', url, false); // synchronous request
post(path, data) {
if (!this.agentConnected) {
console.warn('percy agent not started.');
return;
}
this.xhr.open('post', `${this.agentHost}${path}`, false); // synchronous request
this.xhr.setRequestHeader('Content-Type', 'application/json');
this.xhr.send(JSON.stringify(data));
}
healthCheck() {
try {
this.xhr.open('get', `${this.agentHost}/percy/healthcheck`, false);
this.xhr.onload = () => {
if (this.xhr.status === 200) {
this.agentConnected = true;
}
};
this.xhr.send();
}
catch (_a) {
this.agentConnected = false;
}
}
}

@@ -35,2 +56,3 @@ exports.PercyAgentClient = PercyAgentClient;

this.port = options.port || 5338;
this.client = new percy_agent_client_1.PercyAgentClient(`http://localhost:${this.port}`, this.xhr);
}

@@ -40,4 +62,3 @@ snapshot(name, options = {}) {

let domSnapshot = this.domSnapshot(documentObject);
let percyAgentClient = new percy_agent_client_1.PercyAgentClient(this.xhr);
percyAgentClient.post(`http://localhost:${this.port}/percy/snapshot`, {
this.client.post('/percy/snapshot', {
name,

@@ -44,0 +65,0 @@ url: documentObject.URL,

{
"name": "@percy/agent",
"description": "An agent process for integrating with Percy.",
"version": "0.0.50",
"version": "0.1.0",
"author": "Perceptual Inc",

@@ -6,0 +6,0 @@ "bin": {

@@ -24,3 +24,3 @@ @percy/agent

$ percy (-v|--version|version)
@percy/agent/0.0.50 darwin-x64 node-v8.10.0
@percy/agent/0.1.0 darwin-x64 node-v8.10.0
$ percy --help [COMMAND]

@@ -55,3 +55,3 @@ USAGE

_See code: [dist/commands/exec.ts](https://github.com/percy/percy-agent/blob/v0.0.50/dist/commands/exec.ts)_
_See code: [dist/commands/exec.ts](https://github.com/percy/percy-agent/blob/v0.1.0/dist/commands/exec.ts)_

@@ -74,3 +74,3 @@ ## `percy finalize`

_See code: [dist/commands/finalize.ts](https://github.com/percy/percy-agent/blob/v0.0.50/dist/commands/finalize.ts)_
_See code: [dist/commands/finalize.ts](https://github.com/percy/percy-agent/blob/v0.1.0/dist/commands/finalize.ts)_

@@ -77,0 +77,0 @@ ## `percy help [COMMAND]`

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