After this training session:
- you have a rough overview what Apax is and you know the terms
package manager
library
andregistry
- you know what scopes are and how they are used
- you have knowledge how the content of a package can be defined
- you know the workflow, how an apax package will be created
- you know, how scripts can be added to the apax.yml
- you know that cli parameter can forwarded to scripts
- you've knowledge how a package could be transferred to a registry
Apax is the package manager and build system for ST projects. Apax packages can be used to share code and reuse functionality, just like with any other package manager, but we go a step further and deliver the entire ST build toolchain via packages.
Here you'll find all information for Apax.
Here you'll find explanations for the terms:
- package manger
- registry
- dependency
- library
In order to host repositories not just under your own account but for multiple people you can set up organizations in Github and Gitlab. For example this repository is inside the "simatic-ax" organization. This gives you the advantage of better access right management for all employees in your organization.
When you want to publish your package in a repository that is inside an organization you have to make sure that the project name starts with the name of the organization. In our case we change the name of the project from standardizer-tutorial-lib
to @simatic-ax/standardizer-tutorial-lib
since "simatic-ax" is the name of the organization where this package lies.
-
Before we can create an Apax package, we need to define, what the package shall contain.
-
Open the apax.yml
In the section
files
you seem which folders/files will be shipped with that package. Beside theREADME.md
and theLICENCE.md
the complete folders and subfolders of./src
and./doc
will be shipped. This means, that the package contain the source code and also the documentation for the library. It dos not contain any test code or any binaries.Note: Shipping the compiled binaries instead of the source code is possible, but not part of this tutorial.
-
By excuting the following command in terminal. The key should be created once for the complete department/company
apax keygen --override-existing
The key file will be located in ~/.apax/apax.signkey in the home directory.
Note the
apax pack
need the key to sign the package. -
Users can enter your package scope and public key in the publicKeys section of their apax.yml to detect corruption or manipulation when installing packages.
-
Before you create your package, you've to set the version. Check the current version in the apax.yml
-
In this case the actual version is
0.0.1
. So enter the command:apax version 0.0.2
Result:
The version in the apax.yml will be changed
-
now we're able to create the package with the command:
apax pack
Result: The package with the name
simatic-ax-standardizer-tutorial-lib-0.0.2.apax.tgz
appears in the explorer on the left side.Tip: you can open the *.tgz file with any zip/unzip program
With Apax, you're able to define some own scripts. In this example we create a script which create a package. By execute the command
-
Open the apax.yml
-
Copy the following code into your clipboard
scripts: createlib: - apax build - apax version $1 - apax pack
-
Insert this code into the apax.yml
The apax.yml should look like this:
-
Go to the terminal and enter:
apax createlib 0.0.3
Result: The commands
- apax build
- apax version 0.0.3
- apax pack
will be executed in sequence. In this case the $1 argument will be replaced by 0.0.3 from the command line parameter
At this point, you've a deployable Apax package, which can be uploaded to an registry. This apax.yml is configured in a way, that the package will be published at the GitHub registry in the namespace @simatic-ax
.
In this tutorial, the package can not shipped to our registry
To publish the the package enter:
apax publish --package *.apax.tgz --registry https://npm.pkg.github.com/
Goal reached? Check yourself...
- you have a rough overview what Apax is and you know the terms
package manager
library
andregistry
✔ - you have knowledge how the content of a package can be defined ✔
- you know the workflow, how an apax package will be created ✔
- you know, how scripts can be added to the apax.yml ✔
- you know that cli parameter can forwarded to scripts ✔
- you've knowledge how a package could be transferred to a registry ✔