### Yandex Cloud Service Account Setup for npm Publishing Source: https://context7.com/sourcecraft/yc-cloud-registry-npm.git/llms.txt Provides bash commands to create a service account in Yandex Cloud, assign the necessary role for pushing artifacts to the registry, and generate a key for authentication. The generated key should be uploaded to SourceCraft secrets. ```bash # Создание сервисного аккаунта в Yandex Cloud yc iam service-account create --name npm-publisher # Назначение роли cloud-registry.artifacts.pusher yc resource-manager folder add-access-binding \ --role cloud-registry.artifacts.pusher \ --subject serviceAccount: # Создание ключа для сервисного аккаунта yc iam key create --service-account-name npm-publisher --output key.json # Содержимое key.json загружается в секреты SourceCraft с именем "key" cat key.json ``` -------------------------------- ### Local npm Package Publishing to Yandex Cloud Registry Source: https://context7.com/sourcecraft/yc-cloud-registry-npm.git/llms.txt Guides through the manual process of publishing an npm package to Yandex Cloud Registry without CI/CD. This involves installing Yandex Cloud CLI, authenticating with a service account key, and configuring npm for the private registry. ```bash # Установка Yandex Cloud CLI curl -sSL https://storage.yandexcloud.net/yandexcloud-yc/install.sh | bash # Аутентификация с ключом сервисного аккаунта yc config profile create npm-profile yc config set service-account-key key.json yc config set format json # Получение IAM-токена и настройка npm export NPM_AUTH_TOKEN=$(yc iam create-token | jq -r .iam_token) npm config set //registry.yandexcloud.net/npm/:_authToken=$NPM_AUTH_TOKEN npm config set registry https://registry.yandexcloud.net/npm/ # Установка зависимостей и публикация npm ci npm publish # Проверка публикации npm view sourcecraft-samples-nodejs ``` -------------------------------- ### SourceCraft CI/CD Workflow for npm Publishing Source: https://context7.com/sourcecraft/yc-cloud-registry-npm.git/llms.txt Defines the CI/CD workflow in SourceCraft for automatically publishing npm packages to Yandex Cloud Registry. This configuration triggers on pull requests to the master branch and uses a service account for authentication. ```yaml on: push: - workflows: publish-npm-workflow filter: branches: ["master"] pull_request: - workflows: publish-npm-workflow filter: source_branches: ["**", "!test**"] target_branches: "master" workflows: publish-npm-workflow: tasks: - publish-npm-task tasks: - name: publish-npm-task env: YC_KEY_JSON: ${{ secrets.key }} YC_CLOUD_REGISTRY: https://registry.yandexcloud.net/npm/ cubes: - name: publish-npm-package script: - apt-get install nodejs npm jq -y - curl -o ./yc-install.sh -L https://storage.yandexcloud.net/yandexcloud-yc/install.sh - chmod +x ./yc-install.sh && ./yc-install.sh -i /tmp/yc -n - mv /tmp/yc/bin/yc /usr/bin/yc - echo "$YC_KEY_JSON" > key.json - yc config profile create sa-profile - yc config set service-account-key key.json - export NPM_AUTH_TOKEN=$(yc iam create-token | jq -r .iam_token) - npm config set //registry.yandexcloud.net/npm/:_authToken=$NPM_AUTH_TOKEN - npm config set registry $YC_CLOUD_REGISTRY - npm ci - npm publish ``` -------------------------------- ### Node.js Module Functionality Source: https://context7.com/sourcecraft/yc-cloud-registry-npm.git/llms.txt Demonstrates the basic structure and usage of an exported npm module function. It shows how to import and call the `helloNpm` function and integrate it within an Express.js application for health checks. ```javascript // Импорт модуля const helloNpm = require('sourcecraft-samples-nodejs'); // Вызов функции const message = helloNpm(); console.log(message); // Вывод: "Hello SourceCraft CI/CD" // Использование в Express приложении const express = require('express'); const app = express(); app.get('/health', (req, res) => { res.json({ status: 'ok', message: helloNpm() }); }); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.