# Generic Package to Deploy TGZ packages

**URL:** <https://community.criticalmanufacturing.com/t/generic-package-to-deploy-tgz-packages/695>\
**Category:** Blog\
**Created:** [April 17, 2024, 12:00am UTC](https://community.criticalmanufacturing.com/t/generic-package-to-deploy-tgz-packages/695 "2024-04-17T00:00:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joao\_Roque](https://yyz2.discourse-cdn.com/flex050/user_avatar/community.criticalmanufacturing.com/joao_roque/32/24_2.png) [@Joao\_Roque](https://community.criticalmanufacturing.com/u/Joao_Roque)\
**Post date:** [April 17, 2024, 12:00am UTC](https://community.criticalmanufacturing.com/t/generic-package-to-deploy-tgz-packages/695/1 "2024-04-17T00:00:00Z")

</div>

This post is to illustrate how we can use a generic package to deploy tgz packages.

## Topics

1. Overview and Motivation
2. Generic Package

## Overview and Motivation

It is very common to want to deploy a customization package that is based not on a full customization projects, but holds only some prepacked artifacts. For example when we want to use pre-release versions of product packages but don’t want to include the product source code in our project.

In this example I wanted to generate a deployable package outside of a project scaffolding. This example is mostly valid for Connect IoT / Factory Automation packages, but it can be tweaked for other type of artifacts.

## Generic Package

Let’s first create our root package. A root package requires only the existence of a `cmfpackage.json` that describes this as a root package. We will also add an entry to our package that will hold the tgz files.

```json
{
  "packageId": "Cmf.Custom.DeployTGZ",
  "version": "1.0.0",
  "description": "Package root for deploying TGZ",
  "packageType": "Root",
  "isInstallable": true,
  "isUniqueInstall": false,
  "dependencies": [
    {
      "id": "Cmf.Environment",
      "version": "<%= $CLI_PARAM_MESVersion %>",
      "mandatory": false
    },
    {
      "id": "Cmf.Custom.DeployTGZ.Packages",
      "version": "<%= $CLI_PARAM_MESVersion %>",
      "mandatory": false
    }
  ]
}

```

Now lets create a folder to hold our generic package. Let’s create a new `cmfpackage.json`.

```json
{
  "packageId": "Cmf.Custom.DeployTGZ.Packages",
  "version": "1.0.0",
  "description": "Package to deploy TGZ",
  "packageType": "Generic",
  "isInstallable": true,
  "isUniqueInstall": false,
  "targetDirectory": "UI/Html",
  "targetLayer": "ui",
  "contentToPack": [
    {
      "source": "projects/*.tgz",
      "target": "runtimePackages",
      "ignoreFiles": [
        ".npmignore"
      ]
    }
  ],
  "xmlInjection": [
	"steps.xml",
    "ui.xml"
  ]
}

```

The generic package allows us to configure the build steps and steps to install as we wish. In this case we will not have build steps, but we will inject our deployment steps, in order to deploy the tgz files to the connect iot repository. The content to pack will dictate that the tgz files will be in the `projects/` directory and will be deployed to a folder called runtimePackages. Then we will add a set of injectable steps, these will be joined and parsed to create the deployment metadata.

The ui xml will emulate the devops center options and steps in the GUI.

ui.xml:

```xml

 id="Deployment.ConnectIoT" order="100" title="IoT Configuration" type="generic" requiresValidation="true">
  
	 id="Deployment.Steps.ConnectIoT.Directory" order="0" title="DIRECTORY REPOSITORY" type="generic" requiresValidation="false">
	  
		 name="Local.Repository.Directory.Enabled" readOnly="false" isRequired="false" valueType="Boolean" label="Is Enabled" default="false" />
		 name="Local.Repository.Directory.Location" readOnly="false" isRequired="false" valueType="Text" label="Location" placeholder="Example: C:\repositoryLocation" default="C:\repositoryLocation" />
	  
	
	 id="Deployment.Steps.ConnectIoT.Server" order="1" title="NPM SERVER REPOSITORY" type="generic" requiresValidation="false">
	  
		 name="Local.Repository.Server.Enabled" readOnly="false" isRequired="false" valueType="Boolean" label="Is Enabled" default="false" />
		 name="Local.Repository.Server.Address" readOnly="false" isRequired="false" valueType="Text" label="Address" placeholder="Example: http://127.0.0.1:4873" default="http://127.0.0.1:4873" />
		 name="Publish.Tag" readOnly="false" isRequired="false" valueType="Text" label="Tag" placeholder="Example: latest" default="latest" />
		 name="Local.Repository.Server.UserName" readOnly="false" isRequired="false" valueType="Text" label="Registry User" placeholder="Example: admin" default="admin" />
		 name="Local.Repository.Server.UserPassword" readOnly="false" isRequired="false" valueType="Password" label="Registry User Password" placeholder="Example: password" default="password" />
		 name="Local.Repository.Server.UserEmail" readOnly="false" isRequired="false" valueType="Text" label="Registry User Email" placeholder="Example: admin@companyname.com" default="admin@companyname.com" />
	  
	
  

```

The steps xml will be responsible to determine the actions to be performed. In this case we want not only to deploy but also to generate the repository index.

steps.xml:

```xml
  
    
     type="DeployRepositoryFiles" contentPath="runtimePackages/**" />
     type="GenerateRepositoryIndex" />
  

```

[Download Example Package](https://devblog.criticalmanufacturing.com/blogPosts/plugins/20240417_customization_package_tgz/Cmf.Custom.DeployTGZ.zip)

* * *

## Author

### Hello 👏 , my name is João Roque ✌️

I’ve been working for some years at Critical Manufacturing. I split my time working in the IoT Team and working with the project’s teams. You can visit me at [https://j-roque.com/](https://j-roque.com/) or check me at [LinkedIn](https://www.linkedin.com/in/j-roque/)

Skills: Connect IoT / DevOps

![João Roque](https://canada1.discourse-cdn.com/flex050/uploads/community_criticalmanufacturing/original/1X/1048e9b7f9da629c9532c609c17f0c01471bc3b5.jpeg "IoT Developer Advocate")
_IoT Developer Advocate_

* * *
This is a companion discussion topic for the original entry at [https://devblog.criticalmanufacturing.com/blog/20240417\_customization\_package\_tgz/](https://devblog.criticalmanufacturing.com/blog/20240417_customization_package_tgz/)
