npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

generator-cro

v1.1.6

Published

A generator to scaffold CRO files locally.

Downloads

164

Readme

Optimizely Generator

This configuarble Yeoman generator scaffolds Optimizely files in your local environment and can create an Optimizley experiment in the tool.

Main features:

  • Simple prompts to help build boilerplate templates
  • Capability to setup unlimited custom templates
  • Build JS, CSS and HTML files
  • Extendable to build custom files
  • Build new Optimizely experiments within the Optimizely tool, returning all relevant IDs
  • Fetch existing Optimizley experiments and build local files accordingly, returning all relevant IDs
  • Setup template variables to work with local files or a local server

Getting Started

These instructions will help you install and configure the generator.

Prerequisites

What things you need to install the software and how to install them

Node v18

Installing

Install the npm package

npm i -g [email protected]
npm i 

Configuration File

After installation the configuration file genopti.config.js will have been added to the root of your project. This file is required to setup Optimizely configuartion, custom files and default values. This file is intended to be used for all dvelopers in the project and saved to source control.

Optimizely setup

If either of the Optimizely Auth Token or Project ID are blank the Optimizely prompts will not be present.

Optimizely auth token - this is the Optimizely Personal Access Token, follow these instructions to set one up.

The Optimizely projects array allows you to setup multiple projects. You can select between the projects in the prompts. To set a default project, set the default flag to true.

Each project object requires the Project Name, Auth Token, Audiences (name / id key value pair) and default flag.

Project Name - required the prompts to allow you to select projects. Auth token - required to use the Optimizely REST API Project ID - Optimizely project ID, required to use the Optimizely REST API Audiences - Audience name and ID pairs, these audiences will be automatically added to any Optimizely test created through the API. For example, QA Audiences. Default - set to true to use project as a default

optimizely.projects: [{
       project_name: [PROJECT_NAME],
        auth_token:  [OPTIMIZELY_AUTH_TOKEN],
        project_id: [PROJECT_ID],
        audiences: {
          [AUDIENCE_NAME]: [AUDIENCE_ID],
          [AUDIENCE_NAME]: [AUDIENCE_ID],
        },
        default: [TRUE/FALSE],
}]

Defaults

The default values are used to help personalise the prompts, output file contents and output folder structure.

Child folders (optional). Array of string folder names will create a prompt. This allows for subfolders within the main output destination folder. Allowing for the ability to group tests together.

prompts.config.childFolders: []

Developers (optional) - Array of string names will create a prompt. This adds the developer name to the output files.

prompts.config.developers: []

Homepage URL (optional) - String url to show as an example in a prompt.

prompts.config.homepageUrl: []

Test ID Example (optional) - String - to show as an example in a prompt.

prompts.config.testIdExample: []

Test Name Example (optional) - String - to show as an example in a prompt.

prompts.config.testNameExample: []

Files and Custom Files

During the prompts you will be able to select and deselect which files you want to build for the current test, the files configuration options allows customisation of this prompt.To add more files simply add a new file to the files object (and make sure you add the new files to a custom template folder)

Show In Prompts - Boolean - Make this file available for selection in the prompt.

prompts.files.[filename].showInPrompts:

Checked by default - Boolean - File selected for scaffolding in the prompts or not

prompts.files.[filename].checkedByDefault:

File Extension (optional) - If unset the files object name will be used as the file extension.

prompts.files.[filename].fileExtension:

Single File (optional) - If unset or false then control and variation files will be created for this file type. If set to true a single file will be created for this file type.

prompts.files.[filename].singleFile:

Output

Output desination - the output destination for the tests. A folder will be created in the root if one doesn't already exist.

output.destination: [FOLDER_NAME]

Localhost - if you are using a local server to serve your files then add the server and port here. This will be used to generate the file template variables.

output.localhost: [LOCALHOST_AND_PORT]

Custom Templates

This generator has default templates which can be found in the /templates folder. To add custom templates first add the custom template directory name.

templates.customDirectory: []

Custom template structure

[folder-name] -> src -> [variation folders] -> [variation files]
                       -> [single files]

For example:

checkoutTemplates -> src -> js  -> variation-x.js
                                -> control.js
                                -> shared.js
                         -> css -> variation-x.js
                                -> control.js
                                -> shared.js
                         -> README.md

Template Variables

These variables can be added to any of the templates. To output the values add the variables like this: <%= VARIABLE %>

Test Details Variables

<%= testDetails %>
<%= testId %>
<%= testName %>
<%= testUrl %>
<%= testDescription %>
<%= variations %>
<%= childFolder %>
<%= filesToGenerate %>
<%= developer %>
<%= customTemplate %>

Variation Variables
<%= variations.control.id  %>
<%= variations.control.name %>
<%= variations.index  %>
<%= variations.currentVariation.id %>
<%= variations.currentVariation.name %>
<%= variations.currentVariation.filename %>

Optimizely Variables
<%= optimizely.experimentId %>
<%= optimizely.testType %> 
<%= optimizely.project_name %>

File Path Variables
<%= {folderName}.variation %>
<%= {folderName}.shared  %>
<%= {folderName}.control  %>

Server Path Variables
<%= {folderName}.server.variation %>
<%= {folderName}.server.shared  %>
<%= {folderName}.server.control  %>

Running the tests

npm run test

Break down into end to end tests

Testing verifies the prompt selections generate the correct folder and files outputs

Built With

Authors

  • Chris Davies

License

This project is licensed under the MIT License - see the LICENSE.md file for details