Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PF-132: Adjust validation of tokensTheme in CLI #24

Merged
merged 3 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Deploy to PROD

on:
push:
branches: [main]
# pull_request:
# branches:
# - "main"
# workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 15
env:
TEST_API_URL: https://api.supernova.io/api/v2
TEST_API_KEY: ${{ secrets.SN_API_KEY_PROD }}
TEST_ENVIRONMENT: production
TEST_DOC_ENVIRONMENT: Live
TEST_DESIGN_SYSTEM_ID: 105994
TEST_SYNC_DESIGN_SYSTEM_ID: 105994
TEST_BRAND_ID: 69a8187b-f3d3-4b0f-a892-90afe6a92dcc

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: lts/Hydrogen

- name: Cache node modules
id: cache-npm
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-

- name: Build local exporter
run: cd ${{ github.workspace }}/test-resources/exporter && npm i && npm run build && cd ${{ github.workspace }}

- name: Authenticate with private NPM package
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN_READ }}" > ~/.npmrc

- name: Install dependencies
run: npm i

- name: Build
run: npm run build

- name: Test
run: npm run test

- name: Authenticate with private NPM package for publish
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN_WRITE }}" > ~/.npmrc

- name: Publish to NPM
run: npm run publish-package
10 changes: 7 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ name: Install CLI @PROD
on:
# push:
# branches: [ main ]
pull_request:
branches:
- "main"
# pull_request:
# branches:
# - "main"
workflow_dispatch:
workflow_run:
workflows: ["Deploy to PROD"]
types:
- completed

jobs:
build:
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@supernovaio/cli",
"description": "Supernova.io Command Line Interface",
"version": "1.0.2",
"version": "1.0.3",
"author": "Supernova.io",
"homepage": "https://supernova.io/",
"keywords": [
Expand Down
5 changes: 3 additions & 2 deletions src/utils/figma-tokens-data-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,10 @@ export class FigmaTokensDataLoader {
'Unable to load mapping file: `mapping`.`tokenSets` must be an Array with at least one entry'
)
}
if (map.tokensTheme && (typeof map.tokensTheme !== 'string' || (map.tokensTheme as string).length === 0)) {

if (map.tokensTheme && ((typeof map.tokensTheme !== 'string' && !Array.isArray(map.tokensTheme)) || map.tokensTheme.length === 0)) {
throw new Error(
'Unable to load mapping file: `mapping`.`tokensTheme` must be a non-empty string'
'Unable to load mapping file: `mapping`.`tokensTheme` must be a non-empty string or non-empty array of strings'
)
}
if (!map.supernovaBrand || typeof map.supernovaBrand !== 'string' || map.supernovaBrand.length === 0) {
Expand Down