Skip to content

Commit

Permalink
Release by 27.03.2024 (#1151)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yakutoc authored Mar 28, 2024
2 parents 1d09591 + 2878ad3 commit 6ed48c3
Show file tree
Hide file tree
Showing 589 changed files with 61,944 additions and 19,275 deletions.
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,7 @@ utils/plasma-tokens-utils/*
!utils/plasma-tokens-utils/src

utils/plasma-tokens-native/data

scaffold
!scaffold/template-docs
!scaffold/template-component
52 changes: 34 additions & 18 deletions .github/actions/update-package-lock/action.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,59 @@
name: 'Update package-lock files'
name: 'Update package-lock.json files'

description: 'Update package-lock files after publish RC or latest version'
description: 'Update package-lock.json files after publish RC or latest version'

inputs:
commit-message:
description: 'Commit message when updated package-lock'
required: false
default: 'chore: update package-locks [skip ci]'
default: 'chore: update package-locks.json files [skip ci]'
token:
description: 'A Github Token'
required: true

runs:
using: "composite"
steps:
- name: Update package-lock's
- name: Set options
shell: bash
env:
options: "--no-audit --no-progress --package-lock-only --lockfile-version 2 --legacy-peer-deps"
run: |
# Sync package-lock file state (root level)
npm i ${{ env.options }}
# Remove the node_modules directory from all packages
lerna clean -y
# Sync package-lock files state
lerna exec --no-private -- npm i ${{ env.options }} --ignore-scripts
# root deps don't update correctly on first regeneration O_o
npm i ${{ env.options }}
echo "OPTIONS=--no-audit --no-progress --package-lock-only --lockfile-version 2 --legacy-peer-deps" >> "$GITHUB_ENV"
- name: Sync package-lock's root level
shell: bash
run: npm i --silent ${{ env.OPTIONS }}

- name: Remove the node_modules directory from all packages
shell: bash
run: npx lerna clean -y

- name: Sync package-lock files
uses: nick-fields/[email protected]
with:
shell: bash
timeout_minutes: 5
max_attempts: 3
on_retry_command: |
git reset --hard
npm i --silent ${{ env.OPTIONS }}
command: |
npx lerna exec --no-private -- npm i --silent ${{ env.OPTIONS }} --ignore-scripts
- name: Root deps don't update correctly on first regeneration
shell: bash
run: |
npm i ${{ env.OPTIONS }}
- name: Extract branch name
id: branch_name
id: branch
shell: bash
run: echo "BRANCH=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT

- name: Commit & Push package-lock's
uses: actions-js/push@master
with:
github_token: ${{ inputs.token }}
message: ${{ inputs.commit-message }}
branch: ${{ steps.branch_name.outputs.BRANCH }}
branch: ${{ steps.branch.outputs.BRANCH }}
author_name: Salute Frontend Team
author_email: [email protected]
13 changes: 13 additions & 0 deletions .github/config-ci.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"PACKAGES_CYPRESS": ["plasma-web", "plasma-b2c", "plasma-ui"],
"PACKAGES_DS": [
"plasma-web",
"plasma-b2c",
"plasma-ui",
"plasma-new-hope",
"plasma-asdk",
"caldera",
"caldera-online",
"sdds-serv"
]
}
13 changes: 13 additions & 0 deletions .github/create-links.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = () => {
const { PACKAGES_DS, BASE_URL } = process.env;

const links = JSON.parse(PACKAGES_DS)
.map((item) => {
const name = item.replace('plasma-', '');

return `${name} storybook: ${BASE_URL}/${name}-storybook/`;
})
.join('\n');

return 'Documentation preview deployed!' + '\n\n' + `website:${BASE_URL}/` + '\n' + `${links}`;
};
108 changes: 45 additions & 63 deletions .github/processing-scope.js
Original file line number Diff line number Diff line change
@@ -1,94 +1,76 @@
const CYPRESS_SCOPE = ['@salutejs/plasma-web', '@salutejs/plasma-b2c', '@salutejs/plasma-ui'];
// INFO: HAS_ASSETS - это флаг для управления логикой "@auto-it" плагина upload-assets-extend
// INFO: Изменения в plasma-tokens или plasma-tokens-utils так же повлияют на то что в packagesList окажется plasma-tokens-native

/**
* Define CI config
* @typedef {object} json
* @property {Array<string>} PACKAGES_CYPRESS
* @property {Array<string>} PACKAGES_DS
*/
const CONFIG = require('./config-ci.json');

module.exports = () => {
const { CHANGED_STATE, AS_ENUMERATION } = process.env;
const { RAW_DATA } = process.env;

/**
*
* @param CHANGED_STATE Information about the changed state
* @param CHANGED_STATE.name The name of the package.
* @param CHANGED_STATE.version The version of the package.
* @param CHANGED_STATE.private The type of the package.
* @param CHANGED_STATE.location The path of the package.
* @param RAW_DATA Information about the changed state
* @param RAW_DATA.name The name of the package.
* @param RAW_DATA.version The version of the package.
* @param RAW_DATA.private The type of the package.
* @param RAW_DATA.location The path of the package.
*
* @example
* {
* "name": "@salutejs/plasma-website",
* "version": "0.184.0",
* "private": true,
* "location": "/Users/workspace/plasma/website/plasma-website"
* "location": ".../plasma/website/plasma-website"
* }
*/
const changedState = JSON.parse(JSON.parse(CHANGED_STATE));
const rawData = JSON.parse(RAW_DATA).map(({ name }) => name);

if (!changedState || !changedState.length) {
return { SCOPE: [], HAS_SCOPE: false };
if (!rawData || !rawData.length) {
return {
RAW_DATA: [],
PACKAGES_CYPRESS_RUN: [],
PACKAGES_DOCUMENTATIONS_RUN: [],
PROCESSED_DATA: [],
HAS_PACKAGES_CYPRESS_RUN: false,
HAS_PACKAGES_DS_CHANGES: false,
HAS_ASSETS: false,
};
}

/**
* Processed data - packages name without "@salutejs/"
* @example
* ['@salutejs/plasma-ui-docs', '@salutejs/plasma-ui', '@salutejs/plasma-core']
* ["plasma-web", "plasma-ui", "caldera"]
*/
const packagesList = changedState.map(({ name }) => name);

const HAS_PLASMA_UI_DOCS = packagesList.includes('@salutejs/plasma-ui-docs');
const HAS_PLASMA_WEB_DOCS = packagesList.includes('@salutejs/plasma-web-docs');

const HAS_PLASMA_UI = packagesList.includes('@salutejs/plasma-ui');
const HAS_PLASMA_WEB = packagesList.includes('@salutejs/plasma-web');
const HAS_PLASMA_B2C = packagesList.includes('@salutejs/plasma-b2c');
const HAS_PLASMA_HOPE = packagesList.includes('@salutejs/plasma-new-hope');
const HAS_PLASMA_ASDK = packagesList.includes('@salutejs/plasma-asdk');
const HAS_CALDERA = packagesList.includes('@salutejs/caldera');
const HAS_CALDERA_ONLINE = packagesList.includes('@salutejs/caldera-online');
const HAS_SDDS_SERV = packagesList.includes('@salutejs/sdds-serv');
const HAS_PLASMA_WEBSITE = packagesList.includes('@salutejs/plasma-website');

const HAS_DOCUMENTATION_CHANGED =
HAS_PLASMA_WEBSITE ||
HAS_PLASMA_UI_DOCS ||
HAS_PLASMA_WEB_DOCS ||
HAS_PLASMA_ASDK ||
HAS_CALDERA ||
HAS_CALDERA_ONLINE ||
HAS_SDDS_SERV;

// Флаг для управления логикой "@auto-it" плагина upload-assets-extend
// Изменения в plasma-tokens или plasma-tokens-utils так же повлияют на то что в packagesList окажется plasma-tokens-native
const HAS_ASSETS = packagesList.includes('@salutejs/plasma-tokens-native');
const PROCESSED_DATA = rawData.map((item) => item.replace('@salutejs/', ''));

/**
* List short packages name
* List short packages name for run cypress test
* @example
* ["web", "ui", "b2c"]
*/
const scope = packagesList.filter((item) => CYPRESS_SCOPE.includes(item)).map((item) => `"${item.split('-')[1]}"`);
const PACKAGES_CYPRESS_RUN = PROCESSED_DATA.filter((item) => CONFIG.PACKAGES_CYPRESS.includes(item)).map((item) =>
item.replace('plasma-', ''),
);

/**
* Enumeration packages name
* List packages who has a documentations artifacts: storybook, docusaurus
* @example
* ["plasma-web", "plasma-ui", "plasma-b2c"]
* ["plasma-web", "caldera", "sdds-serv"]
*/
const packagesEnumeration = AS_ENUMERATION === 'true' ? packagesList.map((item) => `"${item.split('/')[1]}"`) : [];

console.log('packagesEnumeration =>', packagesEnumeration);
console.log('packagesList =>', packagesList);
const PACKAGES_DOCUMENTATIONS_RUN = PROCESSED_DATA.filter((item) => CONFIG.PACKAGES_DS.includes(item));

return {
SCOPE: JSON.stringify(scope),
PACKAGES_ENUMERATION: JSON.stringify(packagesEnumeration),
HAS_SCOPE: Boolean(scope.length),
HAS_DOCUMENTATION_CHANGED,
HAS_PLASMA_UI_DOCS,
HAS_PLASMA_WEB_DOCS,
HAS_PLASMA_UI,
HAS_PLASMA_WEB,
HAS_PLASMA_B2C,
HAS_PLASMA_HOPE,
HAS_PLASMA_ASDK,
HAS_ASSETS,
HAS_CALDERA,
HAS_CALDERA_ONLINE,
HAS_SDDS_SERV,
RAW_DATA: JSON.stringify(rawData),
PACKAGES_DOCUMENTATIONS_RUN: JSON.stringify(PACKAGES_DOCUMENTATIONS_RUN),
PACKAGES_CYPRESS_RUN: JSON.stringify(PACKAGES_CYPRESS_RUN),
PROCESSED_DATA: JSON.stringify(PROCESSED_DATA),
HAS_PACKAGES_CYPRESS_RUN: Boolean(PACKAGES_CYPRESS_RUN.length),
HAS_PACKAGES_DS_CHANGES: Boolean(PACKAGES_DOCUMENTATIONS_RUN.length),
HAS_ASSETS: PROCESSED_DATA.includes('plasma-tokens-native'),
};
};
96 changes: 10 additions & 86 deletions .github/workflows/change-detection.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,79 +7,19 @@ on:
description: 'Lerna boostrap filter-option, exclude all transitive dependents when running a command with --since'
default: false
type: boolean
as-enumeration:
description: 'Get scope as "[plasma-core,plasma-ui]", etc'
default: false
type: boolean
ref:
type: string
description: "Manual set repo ref"
default: ''
outputs:
SCOPE:
description: "scope collection"
value: ${{ jobs.run.outputs.SCOPE }}
HAS_SCOPE:
description: "has scope"
value: ${{ jobs.run.outputs.HAS_SCOPE }}
HAS_DOCUMENTATION_CHANGED:
description: ""
value: ${{ jobs.run.outputs.HAS_DOCUMENTATION_CHANGED }}
HAS_PLASMA_UI_DOCS:
description: ""
value: ${{ jobs.run.outputs.HAS_PLASMA_UI_DOCS }}
HAS_PLASMA_WEB_DOCS:
description: ""
value: ${{ jobs.run.outputs.HAS_PLASMA_WEB_DOCS }}
HAS_PLASMA_UI:
description: ""
value: ${{ jobs.run.outputs.HAS_PLASMA_UI }}
HAS_PLASMA_WEB:
description: ""
value: ${{ jobs.run.outputs.HAS_PLASMA_WEB }}
HAS_PLASMA_B2C:
description: ""
value: ${{ jobs.run.outputs.HAS_PLASMA_B2C }}
HAS_PLASMA_HOPE:
description: ""
value: ${{ jobs.run.outputs.HAS_PLASMA_HOPE }}
HAS_PLASMA_ASDK:
description: ""
value: ${{ jobs.run.outputs.HAS_PLASMA_ASDK }}
HAS_CALDERA:
description: ""
value: ${{ jobs.run.outputs.HAS_CALDERA }}
HAS_CALDERA_ONLINE:
description: ""
value: ${{ jobs.run.outputs.HAS_CALDERA_ONLINE }}
HAS_SDDS_SERV:
description: ""
value: ${{ jobs.run.outputs.HAS_SDDS_SERV }}
HAS_ASSETS:
description: ""
value: ${{ jobs.run.outputs.HAS_ASSETS }}
PACKAGES_ENUMERATION:
description: ""
value: ${{ jobs.run.outputs.PACKAGES_ENUMERATION }}
STATE:
description: "state based on changed state of lerna packages"
value: ${{ jobs.run.outputs.STATE }}
jobs:
run:
runs-on: ubuntu-latest
outputs:
SCOPE: ${{ steps.set-output.outputs.SCOPE }}
HAS_SCOPE: ${{ steps.set-output.outputs.HAS_SCOPE }}
HAS_DOCUMENTATION_CHANGED: ${{ steps.set-output.outputs.HAS_DOCUMENTATION_CHANGED }}
HAS_PLASMA_UI_DOCS: ${{ steps.set-output.outputs.HAS_PLASMA_UI_DOCS }}
HAS_PLASMA_WEB_DOCS: ${{ steps.set-output.outputs.HAS_PLASMA_WEB_DOCS }}
HAS_PLASMA_B2C: ${{ steps.set-output.outputs.HAS_PLASMA_B2C }}
HAS_PLASMA_WEB: ${{ steps.set-output.outputs.HAS_PLASMA_WEB }}
HAS_PLASMA_UI: ${{ steps.set-output.outputs.HAS_PLASMA_UI }}
HAS_PLASMA_HOPE: ${{ steps.set-output.outputs.HAS_PLASMA_HOPE }}
HAS_PLASMA_ASDK: ${{ steps.set-output.outputs.HAS_PLASMA_ASDK }}
HAS_CALDERA: ${{ steps.set-output.outputs.HAS_CALDERA }}
HAS_CALDERA_ONLINE: ${{ steps.set-output.outputs.HAS_CALDERA_ONLINE }}
HAS_SDDS_SERV: ${{ steps.set-output.outputs.HAS_SDDS_SERV }}
HAS_ASSETS: ${{ steps.set-output.outputs.HAS_ASSETS }}
PACKAGES_ENUMERATION: ${{ steps.set-output.outputs.PACKAGES_ENUMERATION }}
STATE: ${{ steps.set-output.outputs.STATE }}

steps:
- uses: actions/checkout@v4
Expand All @@ -96,18 +36,16 @@ jobs:
run: echo "EXCLUDE_DEPENDENTS=--exclude-dependents" >> $GITHUB_ENV

- name: Get lerna ls output
shell: bash
id: changed-state
id: lerna-state
run: |
#INFO: `jq -c` => Делаем вывод в одну JSON строку
echo "CHANGED_STATE=$(npx lerna la --json --since=$(git merge-base --fork-point origin/dev) ${{ env.EXCLUDE_DEPENDENTS }} | jq -c)" >> "$GITHUB_OUTPUT"
echo "RAW_DATA=$(npx lerna la --json --since=$(git merge-base --fork-point origin/dev) ${{ env.EXCLUDE_DEPENDENTS }} | jq -c)" >> "$GITHUB_OUTPUT"
- name: Computed scope state
id: scope
uses: actions/github-script@v6
id: state
uses: actions/github-script@v7
env:
CHANGED_STATE: ${{ toJSON(steps.changed-state.outputs.CHANGED_STATE) }}
AS_ENUMERATION: ${{ inputs.as-enumeration }}
RAW_DATA: ${{ steps.lerna-state.outputs.RAW_DATA }}
with:
script: |
const processingScope = require('./.github/processing-scope.js');
Expand All @@ -117,19 +55,5 @@ jobs:
- name: Set "GITHUB_OUTPUT"
id: set-output
run: |
echo "SCOPE=${{ fromJSON(steps.scope.outputs.result).SCOPE }}" >> $GITHUB_OUTPUT
echo "HAS_SCOPE=${{ fromJSON(steps.scope.outputs.result).HAS_SCOPE }}" >> $GITHUB_OUTPUT
echo "HAS_PLASMA_UI_DOCS=${{ fromJSON(steps.scope.outputs.result).HAS_PLASMA_UI_DOCS }}" >> $GITHUB_OUTPUT
echo "HAS_PLASMA_WEB_DOCS=${{ fromJSON(steps.scope.outputs.result).HAS_PLASMA_WEB_DOCS }}" >> $GITHUB_OUTPUT
echo "HAS_DOCUMENTATION_CHANGED=${{ fromJSON(steps.scope.outputs.result).HAS_DOCUMENTATION_CHANGED }}" >> $GITHUB_OUTPUT
echo "HAS_PLASMA_B2C=${{ fromJSON(steps.scope.outputs.result).HAS_PLASMA_B2C }}" >> $GITHUB_OUTPUT
echo "HAS_PLASMA_WEB=${{ fromJSON(steps.scope.outputs.result).HAS_PLASMA_WEB }}" >> $GITHUB_OUTPUT
echo "HAS_PLASMA_UI=${{ fromJSON(steps.scope.outputs.result).HAS_PLASMA_UI }}" >> $GITHUB_OUTPUT
echo "HAS_PLASMA_HOPE=${{ fromJSON(steps.scope.outputs.result).HAS_PLASMA_HOPE }}" >> $GITHUB_OUTPUT
echo "HAS_PLASMA_ASDK=${{ fromJSON(steps.scope.outputs.result).HAS_PLASMA_ASDK }}" >> $GITHUB_OUTPUT
echo "HAS_CALDERA=${{ fromJSON(steps.scope.outputs.result).HAS_CALDERA }}" >> $GITHUB_OUTPUT
echo "HAS_CALDERA_ONLINE=${{ fromJSON(steps.scope.outputs.result).HAS_CALDERA_ONLINE }}" >> $GITHUB_OUTPUT
echo "HAS_SDDS_SERV=${{ fromJSON(steps.scope.outputs.result).HAS_SDDS_SERV }}" >> $GITHUB_OUTPUT
echo "HAS_ASSETS=${{ fromJSON(steps.scope.outputs.result).HAS_ASSETS }}" >> $GITHUB_OUTPUT
echo "PACKAGES_ENUMERATION=${{ fromJSON(steps.scope.outputs.result).PACKAGES_ENUMERATION }}" >> $GITHUB_OUTPUT
echo "STATE=${{ steps.state.outputs.result }}" >> $GITHUB_OUTPUT
Loading

0 comments on commit 6ed48c3

Please sign in to comment.