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

office-addin-environment-manifests

v0.0.2

Published

Generate office Add-In manifest files for different environments based on a template manifest file.

Downloads

1

Readme

Office Add-In environment manifests

Generate office Add-In manifest files for different environments based on a template manifest file.

How to use

There are two main ways to use this package:

  1. As a command line interface
  2. As a function in your bundler configuration/application

Configuration

To use this package properly a configuration has to be supplied. This configuration is expected to have the following format.

interface Environment {
    name: string // Friendly environment name.
    config: object // A key value map of environment variables.
}

interface EnvironmentFile {
    name: string // Friendly environment name.
    path: string // .env file path.
}

interface UserConfig {
    inputTemplateManifestFilePath: string // A filepath to the template manifest file.
    outputManifestFilePath: string // A folder to write the resulting environment manifest files to.
    getOutputManifestFileName(environmentName: string): string // A function for the resulting in environment manifest filenames.
    inputEnvironmentFiles?: EnvironmentFile[] // A array corresponding to the location of the .env files with their friendly name (Optional).
    environmentResolver?(files: EnvironmentFile[] | any): Promise<Environment> // A function to resolve Environments asynchronimously (Optional).
}

Command line usage

For command line usage a config file is needed. The default location for this config file is ./environmentManifests.config.js. You can however specify another location by setting the USER_CONFIG_FILE_PATH environment variable.

Creating a config file

This package uses a javascript module as a config format. This config has to adhere to the following format (see configuration for more information):

module.exports = {} as UserConfig

Config example predefined .env environment files

module.exports = {
    inputTemplateManifestFilePath: './manifest.template.xml',
    outputManifestFilePath: './manifests/',
    getOutputManifestFileName: environment => `manifest.${environment}.xml`,
    inputEnvironmentFiles: [
        {
            name: 'development',
            path: './.env.development'
        },
        {
            name: 'test',
            path: './.env.test'
        }
    ]
}

Function usage

To use this package as a function you simply import it in your program.

example usage

See configuration for more information.

const config = {
    inputTemplateManifestFilePath: './manifest.template.xml',
    outputManifestFilePath: './manifests/',
    getOutputManifestFileName: environment => `manifest.${environment}.xml`,
    inputEnvironmentFiles: [
        {
            name: 'development',
            path: './.env.development'
        },
        {
            name: 'test',
            path: './.env.test'
        }
    ]
}

// This function will return a promise of a warning array.
const warnings = await generateEnvironmentManifests(config)
console.log(warnings)

Creating a template manifest file

A template manifest file is a UTF-8 formatted text file. This package does not parse nor validate the "manifest" files it simply replaces environment variables with a given syntax.

Variable Syntax

In template manifest files you can define variables in the format: {{[name of variable]}}. These variable names have to correlate to the environment variables in your .env file.

Generating a environment manifest files

Let's say we have the following .env file for the development environment:

URL=https://domain.internal/

and we have the following .env file for the test environment:

URL=https://support.github.com/

We create the following template "manifest" file (please use a valid Office Add-in Manifest file):

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<OfficeApp>
    <SupportUrl DefaultValue="{{URL}}"/>
</OfficeApp>

If we execute the package it will produce 2 separate manifest files for the development and test environment using the environment variables respectively:

development
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<OfficeApp>
    <SupportUrl DefaultValue="https://domain.internal/"/>
</OfficeApp>
test
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<OfficeApp>
    <SupportUrl DefaultValue="https://support.github.com/"/>
</OfficeApp>