Skip to content

Commit 12234f8

Browse files
Add support for custom npmrc_path
1 parent 6590fbc commit 12234f8

File tree

7 files changed

+58
-40
lines changed

7 files changed

+58
-40
lines changed

git-commit/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ runs:
1717
using: "composite"
1818
steps:
1919
- name: Setup GIT
20-
uses: raycast/github-actions/setup-git@v1.16.0
20+
uses: raycast/github-actions/setup-git@v1.17.0
2121
- name: Commit
2222
shell: bash
2323
working-directory: ${{ inputs.repo_dir }}

git-post-store-urls-to-pr/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ runs:
1414
using: "composite"
1515
steps:
1616
- name: Setup GIT
17-
uses: raycast/github-actions/setup-git@v1.16.0
17+
uses: raycast/github-actions/setup-git@v1.17.0
1818
- name: Check message
1919
id: check_message
2020
shell: bash

ray-cli/action.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,18 @@ inputs:
1212
access_token:
1313
description: "Raycast Access Token"
1414
required: false
15-
npm_token:
16-
description: "NPM token"
17-
required: false
1815
extension_schema:
1916
description: "Extension schema"
2017
required: false
2118
allow_owners_only_for_extensions:
2219
description: "Whitelist extensions allowed to have owners - each extension in new line. If not set or empty, all extensions are allowe to have it."
2320
required: false
21+
npmrc_path:
22+
description: "Path to npmrc file to access private npm packages"
23+
required: false
24+
raycast_api_alpha_npm_token:
25+
description: "NPM token for alpha version of @raycast/api"
26+
required: false
2427
outputs:
2528
store_urls:
2629
description: "Store URLs for published extensions"
@@ -35,4 +38,4 @@ runs:
3538
GITHUB_WORKSPACE: $GITHUB_WORKSPACE
3639
run: |
3740
set -e -o noglob
38-
${{ github.action_path }}/ray_cli.sh "${{ inputs.command }}" "${{ inputs.paths }}" "${{ inputs.access_token }}" "${{ inputs.npm_token }}" "${{ inputs.extension_schema }}" "${{ inputs.allow_owners_only_for_extensions }}"
41+
${{ github.action_path }}/ray_cli.sh "${{ inputs.command }}" "${{ inputs.paths }}" "${{ inputs.access_token }}" "${{ inputs.extension_schema }}" "${{ inputs.allow_owners_only_for_extensions }}" "${{ inputs.npmrc_path }}" "${{ inputs.raycast_api_alpha_npm_token }}"

ray-cli/ray_cli.sh

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,26 @@ if [ ! -z "$3" ]; then
2222
fi
2323

2424
if [ ! -z "$4" ]; then
25-
npm_token=$4
26-
fi
27-
28-
if [ ! -z "$5" ]; then
29-
extension_schema=$5
25+
extension_schema=$4
3026
else
3127
extension_schema="https://www.raycast.com/schemas/extension.json"
3228
fi
3329

34-
if [ ! -z "$6" ]; then
30+
if [ ! -z "$5" ]; then
3531
SAVEIFS=$IFS
3632
IFS=$'\n'
37-
allow_owners_only_for_extensions=($6)
33+
allow_owners_only_for_extensions=($5)
3834
IFS=$SAVEIFS
3935
fi
4036

37+
if [ ! -z "$6" ]; then
38+
npmrc_path=$6
39+
fi
40+
41+
if [ ! -z "$7" ]; then
42+
raycast_api_alpha_npm_token=$7
43+
fi
44+
4145
function ray_command_from_string() {
4246
case $1 in
4347
build)
@@ -110,17 +114,24 @@ for dir in "${paths[@]}" ; do
110114

111115
### Create .npmrc if needed
112116
cleanup_npmrc=false
113-
api_version=$(jq '.dependencies."@raycast/api"' package.json)
114-
if [[ "$api_version" == *"alpha"* ]]; then
115-
if [ -z "$npm_token" ]; then
116-
echo "::error::Private npm used without npm_token parameter"
117-
exit_code=1
118-
continue
119-
else
120-
echo "//npm.pkg.github.com/:_authToken=$npm_token" > .npmrc
121-
echo "@raycast:registry=https://npm.pkg.github.com" >> .npmrc
122-
echo "legacy-peer-deps=true" >> .npmrc
123-
cleanup_npmrc=true
117+
if [ ! -z "$npmrc_path" ]; then
118+
echo "Using npmrc from $npmrc_path"
119+
cp $npmrc_path .npmrc
120+
cleanup_npmrc=true
121+
else
122+
api_version=$(jq '.dependencies."@raycast/api"' package.json)
123+
if [[ "$api_version" == *"alpha"* ]]; then
124+
if [ -z "$raycast_api_alpha_npm_token" ]; then
125+
echo "::error::Alpha version of @raycast/api used without raycast_api_alpha_npm_token parameter"
126+
exit_code=1
127+
continue
128+
else
129+
echo "Generating .npmrc for alpha version of @raycast/api"
130+
echo "//npm.pkg.github.com/:_authToken=$raycast_api_alpha_npm_token" > .npmrc
131+
echo "@raycast:registry=https://npm.pkg.github.com" >> .npmrc
132+
echo "legacy-peer-deps=true" >> .npmrc
133+
cleanup_npmrc=true
134+
fi
124135
fi
125136
fi
126137

ray/action.yml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,18 @@ inputs:
1515
cli_version:
1616
description: "CLI Version"
1717
required: false
18-
npm_token:
19-
description: "NPM token"
20-
required: false
2118
extension_schema:
2219
description: "Extension schema"
2320
required: false
2421
allow_owners_only_for_extensions:
2522
description: "Whitelist extensions allowed to have owners - each extension in new line. If not set or empty, all extensions are allowe to have it."
2623
required: false
24+
npmrc_path:
25+
description: "Path to npmrc file to access private npm packages"
26+
required: false
27+
raycast_api_alpha_npm_token:
28+
description: "NPM token for alpha version of @raycast/api"
29+
required: false
2730
outputs:
2831
command:
2932
description: "Ray CLI command executed"
@@ -42,29 +45,30 @@ runs:
4245
with:
4346
node-version: 20.15.1
4447
- name: Setup CLI
45-
uses: raycast/github-actions/setup-cli@v1.16.0
48+
uses: raycast/github-actions/setup-cli@v1.17.0
4649
with:
4750
version: ${{ inputs.cli_version || '1.91.1' }}
48-
npm_token: ${{ inputs.npm_token }}
51+
raycast_api_alpha_npm_token: ${{ inputs.raycast_api_alpha_npm_token }}
4952
- name: Get command
5053
id: get_command
51-
uses: raycast/github-actions/get-command@v1.16.0
54+
uses: raycast/github-actions/get-command@v1.17.0
5255
with:
5356
custom_command: ${{ inputs.command }}
5457
github_event_name: ${{ github.event_name }}
5558
- name: Get changed extensions
5659
id: get_changed_extensions
57-
uses: raycast/github-actions/get-changed-extensions@v1.16.0
60+
uses: raycast/github-actions/get-changed-extensions@v1.17.0
5861
with:
5962
custom_paths: ${{ inputs.paths }}
6063
github_event_name: ${{ github.event_name }}
6164
- name: Ray CLI
6265
id: ray_cli
63-
uses: raycast/github-actions/ray-cli@v1.16.0
66+
uses: raycast/github-actions/ray-cli@v1.17.0
6467
with:
6568
paths: ${{ steps.get_changed_extensions.outputs.paths }}
6669
command: ${{ steps.get_command.outputs.command }}
6770
access_token: ${{ inputs.access_token }}
68-
npm_token: ${{ inputs.npm_token }}
6971
extension_schema: ${{ inputs.extension_schema }}
7072
allow_owners_only_for_extensions: ${{ inputs.allow_owners_only_for_extensions }}
73+
npmrc_path: ${{ inputs.npmrc_path }}
74+
raycast_api_alpha_npm_token: ${{ inputs.raycast_api_alpha_npm_token }}

setup-cli/action.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ inputs:
66
version:
77
description: "CLI version (format: 1.0.0)"
88
required: true
9-
npm_token:
10-
description: "NPM token"
9+
raycast_api_alpha_npm_token:
10+
description: "NPM token for alpha version of @raycast/api"
1111
required: false
1212
runs:
1313
using: "composite"
1414
steps:
1515
- name: Setup CLI
1616
shell: bash
1717
run: |
18-
${{ github.action_path }}/setup_cli.sh "${{ inputs.version }}" "${{ inputs.npm_token }}"
18+
${{ github.action_path }}/setup_cli.sh "${{ inputs.version }}" "${{ inputs.raycast_api_alpha_npm_token }}"

setup-cli/setup_cli.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
set -e
44

55
version=$1
6-
npm_token=$2
6+
raycast_api_alpha_npm_token=$2
77

88
if [[ "$version" == *"alpha"* ]]; then
9-
if [ -z "$npm_token" ]; then
10-
echo "::error::Private api used without npm_token parameter"
9+
if [ -z "$raycast_api_alpha_npm_token" ]; then
10+
echo "::error::Alpha version of @raycast/api used without raycast_api_alpha_npm_token parameter"
1111
exit 1
1212
else
13-
echo "//npm.pkg.github.com/:_authToken=$npm_token" > ~/.npmrc
13+
echo "//npm.pkg.github.com/:_authToken=$raycast_api_alpha_npm_token" > ~/.npmrc
1414
echo "@raycast:registry=https://npm.pkg.github.com" >> ~/.npmrc
1515
echo "legacy-peer-deps=true" >> ~/.npmrc
1616
cleanup_npmrc=true

0 commit comments

Comments
 (0)