fix(core): update
This commit is contained in:
parent
8e9a61bbb2
commit
52a8f42fc9
@ -103,6 +103,6 @@ jobs:
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
pnpm install -g @gitzone/tsdoc
|
||||
pnpm install -g @git.zone/tsdoc
|
||||
npmci command tsdoc
|
||||
continue-on-error: true
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env node
|
||||
process.env.CLI_CALL = 'true';
|
||||
|
||||
import * as tsrun from '@gitzone/tsrun';
|
||||
import * as tsrun from '@git.zone/tsrun';
|
||||
tsrun.runPath('./cli.child.js', import.meta.url);
|
||||
|
@ -14,9 +14,24 @@
|
||||
"githost": "gitlab.com",
|
||||
"gitscope": "ship.zone",
|
||||
"gitrepo": "npmci",
|
||||
"description": "node and docker in gitlab ci on steroids",
|
||||
"description": "A tool to enhance Node.js and Docker workflows within GitLab CI, providing various CI/CD utilities.",
|
||||
"npmPackagename": "@ship.zone/npmci",
|
||||
"license": "MIT"
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"Node.js",
|
||||
"Docker",
|
||||
"GitLab CI",
|
||||
"continuous integration",
|
||||
"continuous deployment",
|
||||
"CI/CD",
|
||||
"automation",
|
||||
"npm",
|
||||
"TypeScript",
|
||||
"cloud",
|
||||
"SSH",
|
||||
"registry",
|
||||
"container management"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
27
package.json
27
package.json
@ -2,7 +2,7 @@
|
||||
"name": "@ship.zone/npmci",
|
||||
"version": "4.1.29",
|
||||
"private": false,
|
||||
"description": "node and docker in gitlab ci on steroids",
|
||||
"description": "A tool to enhance Node.js and Docker workflows within GitLab CI, providing various CI/CD utilities.",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"type": "module",
|
||||
@ -26,9 +26,9 @@
|
||||
},
|
||||
"homepage": "https://gitlab.com/gitzone/npmci#README",
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.66",
|
||||
"@gitzone/tsrun": "^1.2.44",
|
||||
"@gitzone/tstest": "^1.0.77",
|
||||
"@git.zone/tsbuild": "^2.1.66",
|
||||
"@git.zone/tsrun": "^1.2.44",
|
||||
"@git.zone/tstest": "^1.0.77",
|
||||
"@push.rocks/tapbundle": "^5.0.15",
|
||||
"@types/node": "^20.5.4"
|
||||
},
|
||||
@ -54,7 +54,7 @@
|
||||
"@push.rocks/smartsocket": "^2.0.22",
|
||||
"@push.rocks/smartssh": "^2.0.1",
|
||||
"@push.rocks/smartstring": "^4.0.8",
|
||||
"@servezone/interfaces": "^1.0.3",
|
||||
"@serve.zone/interfaces": "^1.0.3",
|
||||
"@tsclass/tsclass": "^4.0.42",
|
||||
"@types/through2": "^2.0.38",
|
||||
"through2": "^4.0.2"
|
||||
@ -73,5 +73,20 @@
|
||||
],
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
],
|
||||
"keywords": [
|
||||
"Node.js",
|
||||
"Docker",
|
||||
"GitLab CI",
|
||||
"continuous integration",
|
||||
"continuous deployment",
|
||||
"CI/CD",
|
||||
"automation",
|
||||
"npm",
|
||||
"TypeScript",
|
||||
"cloud",
|
||||
"SSH",
|
||||
"registry",
|
||||
"container management"
|
||||
]
|
||||
}
|
||||
}
|
9439
pnpm-lock.yaml
generated
9439
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
0
readme.hints.md
Normal file
0
readme.hints.md
Normal file
474
readme.md
474
readme.md
@ -1,110 +1,414 @@
|
||||
# @shipzone/npmci
|
||||
```markdown
|
||||
# @ship.zone/npmci
|
||||
node and docker in gitlab ci on steroids
|
||||
|
||||
## Availabililty and Links
|
||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@shipzone/npmci)
|
||||
* [gitlab.com (source)](https://gitlab.com/shipzone/npmci)
|
||||
* [github.com (source mirror)](https://github.com/shipzone/npmci)
|
||||
* [docs (typedoc)](https://shipzone.gitlab.io/npmci/)
|
||||
## Install
|
||||
|
||||
## Status for master
|
||||
To install `@ship.zone/npmci`, you can use npm or yarn:
|
||||
|
||||
Status Category | Status Badge
|
||||
-- | --
|
||||
GitLab Pipelines | [![pipeline status](https://gitlab.com/shipzone/npmci/badges/master/pipeline.svg)](https://lossless.cloud)
|
||||
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/shipzone/npmci/badges/master/coverage.svg)](https://lossless.cloud)
|
||||
npm | [![npm downloads per month](https://badgen.net/npm/dy/@shipzone/npmci)](https://lossless.cloud)
|
||||
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/shipzone/npmci)](https://lossless.cloud)
|
||||
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
|
||||
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
|
||||
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@shipzone/npmci)](https://lossless.cloud)
|
||||
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@shipzone/npmci)](https://lossless.cloud)
|
||||
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@shipzone/npmci)](https://lossless.cloud)
|
||||
```sh
|
||||
# Using npm
|
||||
npm install @ship.zone/npmci
|
||||
|
||||
# Using yarn
|
||||
yarn add @ship.zone/npmci
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Use TypeScript for best in class instellisense.
|
||||
`npmci` is designed to streamline CI/CD processes, particularly in Docker and Node.js environments. The following sections illustrate its usage in various scenarios, from handling Node versions to building Docker images and more.
|
||||
|
||||
npmci is designed to work in docker CI environments. The following docker images come with npmci presinstalled:
|
||||
### 1. Handle Node Versions
|
||||
|
||||
Docker Hub:
|
||||
One of the core features of `npmci` is managing Node versions in your CI environment. You can specify which version of Node to install:
|
||||
|
||||
- [hosttoday/ht-docker-node:npmci](https://hub.docker.com/r/hosttoday/ht-docker-node/)
|
||||
has LTS node version and npmci preinstalled.
|
||||
- [hosttoday/ht-docker-dbase](https://hub.docker.com/r/hosttoday/ht-docker-dbase/)
|
||||
based on docker:git, can be used to build docker images in conjunction with docker:dind
|
||||
```typescript
|
||||
import { Npmci } from '@ship.zone/npmci';
|
||||
|
||||
npmci can be called from commandline and handle a lot of tasks durug ci:
|
||||
async function manageNodeVersions() {
|
||||
const npmciInstance = new Npmci();
|
||||
await npmciInstance.start();
|
||||
|
||||
```shell
|
||||
# Handle node versions
|
||||
npmci node install stable # will install latest stable node version and update PATH for node and npm
|
||||
npmci node install lts # will install latest LTS node version and update PATH for node and npm versions
|
||||
npmci node install legacy # will install latest legacy node version and update PATH for node and npm
|
||||
npmci node install x.x.x # will install any specific node version.
|
||||
await npmciInstance.nodejsManager.handleCli({
|
||||
_: ['node', 'install', 'stable'] // Installs the latest stable version
|
||||
});
|
||||
|
||||
# Handle npm and yarn tasks
|
||||
npmcu npm login # logs in npm using the auth key provided at env var "NPMCI_TOKEN_NPM"
|
||||
npmci npm install # installs dependencies using npm or yarn dependending on availablity
|
||||
npmci npm test # tests the package
|
||||
npmci npm publish # builds a package and publishes it
|
||||
await npmciInstance.nodejsManager.handleCli({
|
||||
_: ['node', 'install', 'lts'] // Installs the Long-Term Support (LTS) version
|
||||
});
|
||||
|
||||
# handle docker tasks
|
||||
npmci docker prepare
|
||||
## npmci test docker will look at all Dockerfiles and look for according tags on GitLab container registry
|
||||
await npmciInstance.nodejsManager.handleCli({
|
||||
_: ['node', 'install', 'legacy'] // Installs a legacy version
|
||||
});
|
||||
|
||||
|
||||
# prepare tools
|
||||
npmci prepare npm # will look for $NPMCI_TOKEN_NPM env var and create .npmrc, so npm is authenticated
|
||||
npmci prepare docker # will look for $NPMCI_LOGIN_DOCKER in form username|password and authenticate docker
|
||||
npmci prepare docker-gitlab # will authenticate docker for gitlab container registry
|
||||
|
||||
# build containers
|
||||
npmci docker build # will build containers
|
||||
## all Dockerfiles named Dockerfile* are picked up.
|
||||
## specify tags like this Dockerfile_[tag]
|
||||
## uploads all built images as [username]/[reponame]:[tag]_test to GitLab
|
||||
## then test in next step with "npmci test docker"
|
||||
|
||||
# publish npm module
|
||||
npmci publish npm # will look vor $NPMCI_TOKEN_NPM env var and push any module in cwd to npm
|
||||
npmci publish docker
|
||||
|
||||
# trigger webhooks
|
||||
npmci trigger # will look for NPMCI_TRIGGER_1 to NPMCI_TRIGGER_100 in form domain|id|token|ref|name
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
npmci supports the use of npmextra.
|
||||
|
||||
To configure npmci create a `npmextra.json` file at the root of your project
|
||||
|
||||
```json
|
||||
{
|
||||
"npmci": {
|
||||
"globalNpmTools": ["npm-check-updates", "protractor", "npmts", "gitzone"]
|
||||
}
|
||||
await npmciInstance.nodejsManager.handleCli({
|
||||
_: ['node', 'install', '14.17.0'] // Install a specific version of Node
|
||||
});
|
||||
}
|
||||
|
||||
manageNodeVersions().then(() => console.log('Node versions managed successfully.'));
|
||||
```
|
||||
|
||||
**Available options**
|
||||
### 2. Handling npm and Yarn Tasks
|
||||
|
||||
| setting | example | description |
|
||||
| -------------- | ----------------------------- | ------------------------------------------------------------------------------------------------- |
|
||||
| globalNpmTools | "globalNpmTools": ["gitbook"] | Will look for the specified package names locally and (if not yet present) install them from npm. |
|
||||
`npmci` provides numerous utilities to streamline npm and yarn workflow tasks within a CI/CD pipeline.
|
||||
|
||||
For further information read the linked docs at the top of this README.
|
||||
```typescript
|
||||
import { Npmci } from '@ship.zone/npmci';
|
||||
|
||||
Use TypeScript for best in class instellisense.
|
||||
async function manageNpmTasks() {
|
||||
const npmciInstance = new Npmci();
|
||||
await npmciInstance.start();
|
||||
|
||||
## Contribution
|
||||
await npmciInstance.npmManager.handleCli({ _: ['npm', 'install'] }); // Installs dependencies
|
||||
await npmciInstance.npmManager.handleCli({ _: ['npm', 'test'] }); // Runs tests
|
||||
await npmciInstance.npmManager.handleCli({ _: ['npm', 'publish'] }); // Publishes the package
|
||||
}
|
||||
|
||||
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
|
||||
manageNpmTasks().then(() => console.log('Npm tasks handled successfully.'));
|
||||
```
|
||||
|
||||
For further information read the linked docs at the top of this readme.
|
||||
### 3. Docker Task Handling
|
||||
|
||||
## Legal
|
||||
> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
|
||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||
`npmci` simplifies Docker operations, particularly in building, testing, and publishing Docker images.
|
||||
|
||||
**Prepare Docker Environment:**
|
||||
|
||||
```typescript
|
||||
import { Npmci } from '@ship.zone/npmci';
|
||||
|
||||
async function prepareDocker() {
|
||||
const npmciInstance = new Npmci();
|
||||
await npmciInstance.start();
|
||||
|
||||
await npmciInstance.dockerManager.handleCli({ _: ['docker', 'prepare'] }); // Prepares Docker environment
|
||||
}
|
||||
|
||||
prepareDocker().then(() => console.log('Docker environment prepared successfully.'));
|
||||
```
|
||||
|
||||
**Building Docker Images:**
|
||||
|
||||
```typescript
|
||||
import { Npmci } from '@ship.zone/npmci';
|
||||
|
||||
async function buildDockerImages() {
|
||||
const npmciInstance = new Npmci();
|
||||
await npmciInstance.start();
|
||||
|
||||
await npmciInstance.dockerManager.handleCli({ _: ['docker', 'build'] }); // Builds Docker images
|
||||
}
|
||||
|
||||
buildDockerImages().then(() => console.log('Docker images built successfully.'));
|
||||
```
|
||||
|
||||
**Testing Docker Images:**
|
||||
|
||||
```typescript
|
||||
import { Npmci } from '@ship.zone/npmci';
|
||||
|
||||
async function testDockerImages() {
|
||||
const npmciInstance = new Npmci();
|
||||
await npmciInstance.start();
|
||||
|
||||
await npmciInstance.dockerManager.handleCli({ _: ['docker', 'test'] }); // Tests Docker images
|
||||
}
|
||||
|
||||
testDockerImages().then(() => console.log('Docker images tested successfully.'));
|
||||
```
|
||||
|
||||
**Publishing Docker Images:**
|
||||
|
||||
```typescript
|
||||
import { Npmci } from '@ship.zone/npmci';
|
||||
|
||||
async function pushDockerImages() {
|
||||
const npmciInstance = new Npmci();
|
||||
await npmciInstance.start();
|
||||
|
||||
await npmciInstance.dockerManager.handleCli({ _: ['docker', 'push'] }); // Pushes Docker images to registry
|
||||
}
|
||||
|
||||
pushDockerImages().then(() => console.log('Docker images pushed successfully.'));
|
||||
```
|
||||
|
||||
### 4. Managing Docker Registries
|
||||
|
||||
`npmci` can handle multiple Docker registries and allows for easy integration within your CI pipeline.
|
||||
|
||||
**Logging in to Docker Registries:**
|
||||
|
||||
```typescript
|
||||
import { Npmci } from '@ship.zone/npmci';
|
||||
|
||||
async function loginToDockerRegistries() {
|
||||
const npmciInstance = new Npmci();
|
||||
await npmciInstance.start();
|
||||
|
||||
await npmciInstance.dockerManager.handleCli({ _: ['docker', 'login'] }); // Logs into all configured Docker registries
|
||||
}
|
||||
|
||||
loginToDockerRegistries().then(() => console.log('Logged into Docker registries.'));
|
||||
```
|
||||
|
||||
**Pulling Docker Images:**
|
||||
|
||||
```typescript
|
||||
import { Npmci } from '@ship.zone/npmci';
|
||||
|
||||
async function pullDockerImages() {
|
||||
const npmciInstance = new Npmci();
|
||||
await npmciInstance.start();
|
||||
|
||||
await npmciInstance.dockerManager.handleCli({ _: ['docker', 'pull', 'registry.gitlab.com/mygroup/myrepo'] }); // Pulls Docker images from a registry
|
||||
}
|
||||
|
||||
pullDockerImages().then(() => console.log('Docker images pulled successfully.'));
|
||||
```
|
||||
|
||||
### 5. SSH Key Management
|
||||
|
||||
`npmci` also simplifies the management of SSH keys, which is crucial for accessing private repositories and servers.
|
||||
|
||||
**Preparing SSH Keys:**
|
||||
|
||||
```typescript
|
||||
import { Npmci } from '@ship.zone/npmci';
|
||||
|
||||
async function prepareSshKeys() {
|
||||
const npmciInstance = new Npmci();
|
||||
await npmciInstance.start();
|
||||
|
||||
await npmciInstance.sshManager.handleCli({ _: ['ssh', 'prepare'] }); // Prepares SSH keys from environment variables
|
||||
}
|
||||
|
||||
prepareSshKeys().then(() => console.log('SSH keys prepared successfully.'));
|
||||
```
|
||||
|
||||
### 6. Cloudron Integration
|
||||
|
||||
For users deploying applications on Cloudron, `npmci` provides a set of utilities for automating Cloudron tasks.
|
||||
|
||||
**Deploying to Cloudron:**
|
||||
|
||||
```typescript
|
||||
import { Npmci } from '@ship.zone/npmci';
|
||||
|
||||
async function deployToCloudron() {
|
||||
const npmciInstance = new Npmci();
|
||||
await npmciInstance.start();
|
||||
|
||||
await npmciInstance.cloudronManager.handleCli({
|
||||
_: ['cloudron', 'deploy']
|
||||
}); // Deploys application to Cloudron platform
|
||||
}
|
||||
|
||||
deployToCloudron().then(() => console.log('Deployment to Cloudron completed.'));
|
||||
```
|
||||
|
||||
**Preparing Cloudron Manifest:**
|
||||
Before deployment, replace version placeholders in the Cloudron Manifest:
|
||||
|
||||
```typescript
|
||||
import { Npmci } from '@ship.zone/npmci';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
async function prepareCloudronManifest(version: string) {
|
||||
const manifestPath = path.join(process.cwd(), "CloudronManifest.json");
|
||||
let manifestFile = fs.readFileSync(manifestPath, { encoding: 'utf-8' });
|
||||
manifestFile = manifestFile.replace(/##version##/g, version);
|
||||
fs.writeFileSync(manifestPath, manifestFile);
|
||||
console.log('CloudronManifest prepared');
|
||||
}
|
||||
|
||||
async function deployWithPreparedManifest() {
|
||||
const npmciInstance = new Npmci();
|
||||
await npmciInstance.start();
|
||||
|
||||
await prepareCloudronManifest('1.0.0');
|
||||
await npmciInstance.cloudronManager.handleCli({
|
||||
_: ['cloudron', 'deploy']
|
||||
}); // Deploys application to Cloudron platform
|
||||
}
|
||||
|
||||
deployWithPreparedManifest().then(() => console.log('Deployment to Cloudron with manifest preparation completed.'));
|
||||
```
|
||||
|
||||
### 7. Webhook Triggers
|
||||
|
||||
`npmci` supports webhook triggers, allowing you to trigger builds and other activities based on various conditions.
|
||||
|
||||
**Triggering Webhooks:**
|
||||
|
||||
```typescript
|
||||
import { Npmci } from '@ship.zone/npmci';
|
||||
|
||||
async function triggerWebhooks() {
|
||||
const npmciInstance = new Npmci();
|
||||
await npmciInstance.start();
|
||||
|
||||
await npmciInstance.triggerManager.handleCli({
|
||||
_: ['trigger']
|
||||
}); // Triggers webhooks based on environment variables
|
||||
}
|
||||
|
||||
triggerWebhooks().then(() => console.log('Webhooks triggered successfully.'));
|
||||
```
|
||||
|
||||
### 8. Using the bash Helper
|
||||
|
||||
`npmci` includes a bash helper for executing commands within a bash shell, useful for various custom tasks.
|
||||
|
||||
**Using bash to Execute Commands:**
|
||||
|
||||
```typescript
|
||||
import { bash } from '@ship.zone/npmci';
|
||||
|
||||
async function runCustomBashCommand(command: string) {
|
||||
const output = await bash(command);
|
||||
console.log('Command output:', output);
|
||||
}
|
||||
|
||||
runCustomBashCommand('echo Hello World').then(() => console.log('Custom command executed successfully.'));
|
||||
```
|
||||
|
||||
### 9. Example CI Configuration
|
||||
|
||||
An example of integrating `npmci` into a GitLab CI configuration might look like this:
|
||||
|
||||
```yaml
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
|
||||
stages:
|
||||
- prepare
|
||||
- build
|
||||
- test
|
||||
- deploy
|
||||
|
||||
default:
|
||||
before_script:
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
|
||||
prepare:
|
||||
stage: prepare
|
||||
script:
|
||||
- npmci prepare npm
|
||||
- npmci prepare docker
|
||||
|
||||
build:
|
||||
stage: build
|
||||
script:
|
||||
- npmci docker build
|
||||
|
||||
test:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm test
|
||||
|
||||
deploy:
|
||||
stage: deploy
|
||||
script:
|
||||
- npmci publish npm
|
||||
- npmci docker push
|
||||
- npmci cloudron deploy
|
||||
|
||||
environment:
|
||||
name: production
|
||||
url: http://example.com
|
||||
```
|
||||
|
||||
This example YAML file configures stages for preparing the environment, building the project, running tests, and deploying the project. `npmci` commands are used throughout to handle various tasks.
|
||||
|
||||
## Full Features and Use Cases
|
||||
|
||||
Below is a comprehensive set of features and use cases supported by `npmci`. This section ensures you can take full advantage of the library's capabilities in multiple scenarios.
|
||||
|
||||
### Comprehensive Docker Workflow
|
||||
|
||||
**Step-by-step Docker Image Handling:**
|
||||
|
||||
1. **Detect and Build All Dockerfiles:**
|
||||
|
||||
```typescript
|
||||
import { Npmci } from '@ship.zone/npmci';
|
||||
|
||||
async function detectAndBuildDockerfiles() {
|
||||
const npmciInstance = new Npmci();
|
||||
await npmciInstance.start();
|
||||
const dockerfiles = await npmciInstance.dockerManager.getDockerfiles();
|
||||
console.log('Dockerfiles detected:', dockerfiles.map(d => d.filePath));
|
||||
|
||||
await npmciInstance.dockerManager.handleCli({ _: ['docker', 'build'] });
|
||||
console.log('Dockerfiles built successfully.');
|
||||
}
|
||||
|
||||
detectAndBuildDockerfiles().then(() => console.log('Docker detection and build process completed.'));
|
||||
```
|
||||
|
||||
2. **Test All Dockerfiles:**
|
||||
|
||||
```typescript
|
||||
import { Npmci } from '@ship.zone/npmci';
|
||||
|
||||
async function testAllDockerfiles() {
|
||||
const npmciInstance = new Npmci();
|
||||
await npmciInstance.start();
|
||||
await npmciInstance.dockerManager.handleCli({ _: ['docker', 'test'] });
|
||||
console.log('Dockerfiles tested successfully.');
|
||||
}
|
||||
|
||||
testAllDockerfiles().then(() => console.log('Docker testing process completed.'));
|
||||
```
|
||||
|
||||
3. **Push Dockerfiles to a Registry:**
|
||||
|
||||
```typescript
|
||||
import { Npmci } from '@ship.zone/npmci';
|
||||
|
||||
async function pushDockerfilesToRegistry() {
|
||||
const npmciInstance = new Npmci();
|
||||
await npmciInstance.start();
|
||||
|
||||
await npmciInstance.dockerManager.handleCli({ _: ['docker', 'push'] });
|
||||
console.log('Dockerfiles pushed to registry successfully.');
|
||||
}
|
||||
|
||||
pushDockerfilesToRegistry().then(() => console.log('Docker push process completed.'));
|
||||
```
|
||||
|
||||
**Dockerfile Class Example:**
|
||||
|
||||
Here's a snippet showcasing how the `Dockerfile` class can be used to handle Dockerfile-specific operations:
|
||||
|
||||
```typescript
|
||||
import { Dockerfile } from '@ship.zone/npmci';
|
||||
|
||||
async function handleDockerfileOperations() {
|
||||
// Initialize Dockerfile instances
|
||||
const dockerfile1 = new Dockerfile(/* required parameters */);
|
||||
const dockerfile2 = new Dockerfile(/* required parameters */);
|
||||
|
||||
// Read and sort Dockerfiles
|
||||
const dockerfiles = await Dockerfile.readDockerfiles(/* required parameters */);
|
||||
const sortedDockerfiles = await Dockerfile.sortDockerfiles(dockerfiles);
|
||||
|
||||
// Build and Test Dockerfiles
|
||||
await Dockerfile.buildDockerfiles(sortedDockerfiles);
|
||||
await Dockerfile.testDockerfiles(sortedDockerfiles);
|
||||
|
||||
// Push Dockerfile images to a registry
|
||||
for (const dockerfile of sortedDockerfiles) {
|
||||
await dockerfile.push(/* registry and tag parameters */);
|
||||
}
|
||||
|
||||
console.log('Dockerfile operations completed successfully.');
|
||||
}
|
||||
|
||||
handleDockerfileOperations().then(() => console.log('Dockerfile processing flow completed.'));
|
||||
```
|
||||
|
||||
This completes the comprehensive guide to `@ship.zone/npmci`. With the examples and explanations provided, you should be able to harness the full power and flexibility of the library to streamline your CI/CD processes effectively.
|
||||
```
|
||||
undefined
|
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@ship.zone/npmci',
|
||||
version: '4.1.29',
|
||||
description: 'node and docker in gitlab ci on steroids'
|
||||
version: '4.1.30',
|
||||
description: 'A tool to enhance Node.js and Docker workflows within GitLab CI, providing various CI/CD utilities.'
|
||||
}
|
||||
|
@ -3,8 +3,12 @@
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "ES2022",
|
||||
"moduleResolution": "nodenext",
|
||||
"esModuleInterop": true
|
||||
}
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"esModuleInterop": true,
|
||||
"verbatimModuleSyntax": true
|
||||
},
|
||||
"exclude": [
|
||||
"dist_*/**/*.d.ts"
|
||||
]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user