fix(core): update

This commit is contained in:
Philipp Kunz 2024-05-24 15:54:32 +02:00
parent 6e4c967917
commit 9eaa6347c1
5 changed files with 157 additions and 71 deletions

View File

@ -14,15 +14,15 @@
"githost": "gitlab.com", "githost": "gitlab.com",
"gitscope": "ship.zone", "gitscope": "ship.zone",
"gitrepo": "npmci", "gitrepo": "npmci",
"description": "A tool to enhance Node.js and Docker workflows within GitLab CI, providing various CI/CD utilities.", "description": "A tool to streamline Node.js and Docker workflows within CI environments, particularly GitLab CI, providing various CI/CD utilities.",
"npmPackagename": "@ship.zone/npmci", "npmPackagename": "@ship.zone/npmci",
"license": "MIT", "license": "MIT",
"keywords": [ "keywords": [
"Node.js", "Node.js",
"Docker", "Docker",
"GitLab CI", "GitLab CI",
"continuous integration", "GitHub CI",
"continuous deployment", "Gitea CI",
"CI/CD", "CI/CD",
"automation", "automation",
"npm", "npm",
@ -30,7 +30,9 @@
"cloud", "cloud",
"SSH", "SSH",
"registry", "registry",
"container management" "container management",
"continuous integration",
"continuous deployment"
] ]
} }
} }

View File

@ -2,7 +2,7 @@
"name": "@ship.zone/npmci", "name": "@ship.zone/npmci",
"version": "4.1.30", "version": "4.1.30",
"private": false, "private": false,
"description": "A tool to enhance Node.js and Docker workflows within GitLab CI, providing various CI/CD utilities.", "description": "A tool to streamline Node.js and Docker workflows within CI environments, particularly GitLab CI, providing various CI/CD utilities.",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts", "typings": "dist_ts/index.d.ts",
"type": "module", "type": "module",
@ -78,8 +78,8 @@
"Node.js", "Node.js",
"Docker", "Docker",
"GitLab CI", "GitLab CI",
"continuous integration", "GitHub CI",
"continuous deployment", "Gitea CI",
"CI/CD", "CI/CD",
"automation", "automation",
"npm", "npm",
@ -87,6 +87,8 @@
"cloud", "cloud",
"SSH", "SSH",
"registry", "registry",
"container management" "container management",
"continuous integration",
"continuous deployment"
] ]
} }

View File

@ -0,0 +1,2 @@
- focus on cli usage in CI environments.
- show Gitlab CI, GitHub CI and Gitea CI examples.

200
readme.md
View File

@ -1,6 +1,5 @@
```markdown
# @ship.zone/npmci # @ship.zone/npmci
node and docker in gitlab ci on steroids A tool to enhance Node.js and Docker workflows within GitLab CI, providing various CI/CD utilities.
## Install ## Install
@ -18,7 +17,137 @@ yarn add @ship.zone/npmci
`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 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.
### 1. Handle Node Versions ### 1. Integration with GitLab CI, GitHub CI, and Gitea CI
#### GitLab CI
An example of integrating `npmci` into a GitLab CI configuration could 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
environment:
name: production
url: http://example.com
```
#### GitHub Actions
Similarly, you can set up `npmci` in GitHub Actions:
```yaml
name: CI Pipeline
on:
push:
branches:
- main
jobs:
prepare:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '14'
- run: npm install -g @ship.zone/npmci
- run: npmci node install stable
- run: npmci npm install
build:
runs-on: ubuntu-latest
needs: prepare
steps:
- run: npmci docker build
test:
runs-on: ubuntu-latest
needs: build
steps:
- run: npmci npm test
deploy:
runs-on: ubuntu-latest
needs: test
steps:
- run: npmci publish npm
- run: npmci docker push
```
#### Gitea CI
Lastly, for Gitea CI:
```yaml
image: hosttoday/ht-docker-node:npmci
pipelines:
default:
- step:
name: Prepare
image: hosttoday/ht-docker-node:npmci
commands:
- npmci node install stable
- npmci npm install
- npmci prepare npm
- npmci prepare docker
- step:
name: Build
image: hosttoday/ht-docker-node:npmci
commands:
- npmci docker build
- step:
name: Test
image: hosttoday/ht-docker-node:npmci
commands:
- npmci npm test
- step:
name: Deploy
image: hosttoday/ht-docker-node:npmci
commands:
- npmci publish npm
- npmci docker push
```
### 2. Handle Node Versions
One of the core features of `npmci` is managing Node versions in your CI environment. You can specify which version of Node to install: One of the core features of `npmci` is managing Node versions in your CI environment. You can specify which version of Node to install:
@ -49,7 +178,7 @@ async function manageNodeVersions() {
manageNodeVersions().then(() => console.log('Node versions managed successfully.')); manageNodeVersions().then(() => console.log('Node versions managed successfully.'));
``` ```
### 2. Handling npm and Yarn Tasks ### 3. Handling npm and Yarn Tasks
`npmci` provides numerous utilities to streamline npm and yarn workflow tasks within a CI/CD pipeline. `npmci` provides numerous utilities to streamline npm and yarn workflow tasks within a CI/CD pipeline.
@ -68,7 +197,7 @@ async function manageNpmTasks() {
manageNpmTasks().then(() => console.log('Npm tasks handled successfully.')); manageNpmTasks().then(() => console.log('Npm tasks handled successfully.'));
``` ```
### 3. Docker Task Handling ### 4. Docker Task Handling
`npmci` simplifies Docker operations, particularly in building, testing, and publishing Docker images. `npmci` simplifies Docker operations, particularly in building, testing, and publishing Docker images.
@ -132,7 +261,7 @@ async function pushDockerImages() {
pushDockerImages().then(() => console.log('Docker images pushed successfully.')); pushDockerImages().then(() => console.log('Docker images pushed successfully.'));
``` ```
### 4. Managing Docker Registries ### 5. Managing Docker Registries
`npmci` can handle multiple Docker registries and allows for easy integration within your CI pipeline. `npmci` can handle multiple Docker registries and allows for easy integration within your CI pipeline.
@ -166,7 +295,7 @@ async function pullDockerImages() {
pullDockerImages().then(() => console.log('Docker images pulled successfully.')); pullDockerImages().then(() => console.log('Docker images pulled successfully.'));
``` ```
### 5. SSH Key Management ### 6. SSH Key Management
`npmci` also simplifies the management of SSH keys, which is crucial for accessing private repositories and servers. `npmci` also simplifies the management of SSH keys, which is crucial for accessing private repositories and servers.
@ -185,7 +314,7 @@ async function prepareSshKeys() {
prepareSshKeys().then(() => console.log('SSH keys prepared successfully.')); prepareSshKeys().then(() => console.log('SSH keys prepared successfully.'));
``` ```
### 6. Cloudron Integration ### 7. Cloudron Integration
For users deploying applications on Cloudron, `npmci` provides a set of utilities for automating Cloudron tasks. For users deploying applications on Cloudron, `npmci` provides a set of utilities for automating Cloudron tasks.
@ -235,7 +364,7 @@ async function deployWithPreparedManifest() {
deployWithPreparedManifest().then(() => console.log('Deployment to Cloudron with manifest preparation completed.')); deployWithPreparedManifest().then(() => console.log('Deployment to Cloudron with manifest preparation completed.'));
``` ```
### 7. Webhook Triggers ### 8. Webhook Triggers
`npmci` supports webhook triggers, allowing you to trigger builds and other activities based on various conditions. `npmci` supports webhook triggers, allowing you to trigger builds and other activities based on various conditions.
@ -256,7 +385,7 @@ async function triggerWebhooks() {
triggerWebhooks().then(() => console.log('Webhooks triggered successfully.')); triggerWebhooks().then(() => console.log('Webhooks triggered successfully.'));
``` ```
### 8. Using the bash Helper ### 9. Using the bash Helper
`npmci` includes a bash helper for executing commands within a bash shell, useful for various custom tasks. `npmci` includes a bash helper for executing commands within a bash shell, useful for various custom tasks.
@ -273,55 +402,7 @@ async function runCustomBashCommand(command: string) {
runCustomBashCommand('echo Hello World').then(() => console.log('Custom command executed successfully.')); runCustomBashCommand('echo Hello World').then(() => console.log('Custom command executed successfully.'));
``` ```
### 9. Example CI Configuration ### Full Features and Use Cases
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. 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.
@ -410,5 +491,4 @@ handleDockerfileOperations().then(() => console.log('Dockerfile processing flow
``` ```
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. 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 undefined

View File

@ -3,6 +3,6 @@
*/ */
export const commitinfo = { export const commitinfo = {
name: '@ship.zone/npmci', name: '@ship.zone/npmci',
version: '4.1.30', version: '4.1.31',
description: 'A tool to enhance Node.js and Docker workflows within GitLab CI, providing various CI/CD utilities.' description: 'A tool to streamline Node.js and Docker workflows within CI environments, particularly GitLab CI, providing various CI/CD utilities.'
} }